Can someone explain the following command?
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user1'#'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES
This gives the user specified later in the command all privileges.
http://dev.mysql.com/doc/refman/5.7/en/grant.html
ON *.*
Matches everything.
TO 'user1'#'localhost'
The user with name ‘user1’ on localhost which is to be granted the privileges.
WITH GRANT OPTION
The GRANT OPTION privilege enables you to give to other users or remove from other users those privileges that you yourself possess.
https://dev.mysql.com/doc/refman/5.6/en/privileges-provided.html#priv_grant-option
Related
Is it possible to give grant to user by another user? I've created user with full privileges:
CRETAE USER test#localhost IDENTIFIED BY 'test';
GRANT ALL ON *.* TO test#localhost;
GRANT CREATE USER ON *.* TO test#localhost;
FLUSH PRIVILEGES;
But when I tried to give privileges to another user using user 'test' It is written "Access denied to user test#localhost for table 'x'"
Updated: I found the way by edditing Grant_priv mysql.user is there any syntax for that?
The syntax is WITH GRANT OPTION.
CREATE USER test#localhost IDENTIFIED BY 'test';
GRANT ALL ON *.* TO test#localhost WITH GRANT OPTION;
...
How to grant all privileges to all users in mySQL ?
GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'#'1.2.3.4' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
What do I replace username with in order to allow it for every user on the given IP?Even if it is '' i.e no username at all in input ?
I tried * and % in username but that did not help.
You can try like this:
GRANT ALL PRIVILEGES ON *.* TO ''#'localhost' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
The manual says:
In this case, any user who connects from the local host with the
correct password for the anonymous user will be permitted access, with
the privileges associated with the anonymous-user account.
This is working for all my MySQL users irrespective of their hostname and Ips.
GRANT ALL ON <yourdbname>.* TO ''#'%' IDENTIFIED BY 'yourdbpassword';
FLUSH PRIVILEGES;
This should work:
GRANT ALL PRIVILEGES ON 'database'.'table' TO '%'#'1.2.3.4' WITH GRANT OPTION;
Wild card does not work for user in mysql grant privilege command.
If you know list of users then yOU can try :-
GRANT ALL PRIVILEGES ON *.* TO 'user1'#'1.2.3.4',
'user2'#'1.2.3.4',
'user3'#'1.2.3.4',
'user4'#'1.2.3.4',
'user5'#'1.2.3.4',
'user6'#'1.2.3.4';
If you want to grant all privileges to all users and be able to use without a password, the command:
GRANT ALL PRIVILEGES ON *.* TO ''#'%' IDENTIFIED BY '' WITH GRANT OPTION;
If, for example you hava database named 'my_db' and you doing operations from localhost, the command can be the follow:
GRANT ALL PRIVILEGES ON my_db.* TO ''#'localhsot' IDENTIFIED BY '' WITH GRANT OPTION;
MySQL does not support wildcards in user names, so you cannot do that in a single grant.
see the official doc
I have a user called test, and I want to grant process privilege to him.
So far, I have tried:
grant process on *.* to test;
FLUSH PRIVILEGES;
then, I show all grants for user test by running:
show grants for test#'%';
the result does contain a `PROCESS' line like:
GRANT PROCESS ON *.* TO 'test'#'%' IDENTIFIED BY PASSWORD ...
...
...
But it didn't appear to work for user test.
So, how can I grant PROCESS privilege to a user?
This should do:
GRANT PROCESS, SELECT ON *.* ...
mysql> GRANT ALL PRIVILEGES ON mydb.* TO 'myuser'#'%' WITH GRANT OPTION;
Or Try
CREATE USER 'newuser'#'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON * . * TO 'newuser'#'localhost';
FLUSH PRIVILEGES;
than Run
SELECT User FROM mysql.user;
you will find the User created by you, if you want to see Privileges of all users than run
SELECT * FROM mysql.user;
Finally to see Grant Information try
SELECT * FROM information_schema.user_privileges;
While logging into MySQL using 'root'#10.0.1.15'
I tried to grant a user SELECT, INSERT, UPDATE but got this error from MySQL
Error Code: 1044. Access denied for user 'root'#'10.%' to database 'abc'
This is the query that I used to grant
GRANT SELECT, INSERT, UPDATE ON abc.* TO 'myUser'#'10.%';
This makes no since because when I execute SHOW GRANTS FOR 'root'#'10.%' Here is what I get
GRANT ALL PRIVILEGES ON *.* TO 'root'#'10.%' IDENTIFIED BY PASSWORD 'jklasdfksfkashdfksdfhsdlkfasdfjklasdfsjk'
I tried to do grant all privileges all over again but still getting the same error.
GRANT ALL PRIVILEGES ON *.* TO 'root'#'10.%';
FLUSH PRIVILEGES;
What I could be doing wrong here? why aren't the user 'root'#'10.0.1.15' able to GRANT other users privileges?
Your user needs the GRANT OPTION.
Here's how to change your existing grant to fix that:
GRANT ALL PRIVILEGES ON *.*
TO 'root'#'10.%'
IDENTIFIED BY PASSWORD 'jklasdfksfkashdfksdfhsdlkfasdfjklasdfsjk'
WITH GRANT OPTION
In mysql i executed following command
REVOKE ALL PRIVILEGES
after that i try to give GRANT then it shows Access denied
it would seem that you revoked the GRANT privileges of your own user, you should use the root user to grant those privileges back.
for a review of your status regarding the privileges run from root user:
SHOW GRANTS;