what's wrong with the grant all command? - mysql

grant all privileges on 'bbs' to 'userone'#'localhost' IDENTIFIED BY PASSWORD 'user2012';
It shows ERROR 1064 (42000): You have an error in your SQL syntax; check the manual
I want to add a user userone and grant all privileges to the database bbs.
How to correct it?

You need to include an indicator for the tables in the database you want to grant the privilege. Change the query:
grant all privileges on bbs.* to 'userone'#'localhost' IDENTIFIED BY PASSWORD 'user2012';
to grant it for all the tables in the 'bbs' database.

Leave the ' at the table name:
grant all privileges on bbs to 'userone'#'localhost' IDENTIFIED BY PASSWORD 'user2012';

grant all privileges on 'bbs.*' to 'userone'#'localhost' identified by ‘user2012’;

Related

Grant all privileges to root user in MySQL 8.0.21

I am aware that this question has been asked already on stackoverflow but I don't see any answer for the actual question posted. Hence posting again.
GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED BY PASSWORD 'abcd' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'#'::1' IDENTIFIED BY PASSWORD 'abcd' WITH GRANT OPTION;
Above lines throw
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY PASSWORD 'abcd' WITH GRANT OP' at line 1
I am trying to upgrade mysql from 5.7 to latest 8.0.21
Thanks!
For GRANT ALL privileges to root user use the following syntax:
GRANT ALL PRIVILEGES ON database_name.* TO 'root'#'localhost';
FLUSH PRIVILEGES;
The above grant mysql command defines that:
GRANT the PRIVILEGES of type ALL
These privileges are for a particular database named dbname and it applies to all tables of that database indicated by the .* that follows the dbname.
These privileges are assigned to username when that username is connected through locally, as specified by #'localhost'.
You can change to specify any valid host, replace 'localhost' with '%'.

How to grant all privileges to specific user to remote ip

This command work
GRANT ALL ON hmremote.* TO 'uber'#'localhost';
but this don't
GRANT ALL ON hmremote.* TO 'uber'#'111.111.111.111';
ERROR 1410 (42000): You are not allowed to create a user with GRANT
Also tried with.
GRANT ALL ON hmremote.* TO 'uber'#'111.111.111.111' IDENTIFIED BY 'password';
What did I do wrong? Thanks in advance.
Try using CREATE USER uber#111.111.111.111 before you grant permissions.

ERROR 1064 (42000): You have an error in your SQL syntax; to set permission

this is my command to give grant permission to the user to the database
grant all on 'puppet'.* to 'puppet'#'%';
Looking in depth on this page about granting permission:
It looks like you're trying to create a superuser ? If so, you're missing one * On your command, which should be like this :
grant all priviliges on *.* to 'puppet'#'%'
If you're not creating a superuser, then your command should be like this :
GRANT ALL PRIVILEGES ON database_name.* TO 'username'#'localhost';
Hope this helps !

How can I give CREATE USER and GRANT privileges to an user in MySQL?

I created a new user called Hamza in localhost then I tried to give it these 2 privileges:
CREATE USER
GRANT
For the creation everything is OK, but when it comes to granting the privileges I tried this query :
GRANT CREATE USER TO 'Hamza'#'localhost' WITH GRANT OPTION;
And I got this error :
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TO 'Hamza'#'localhost' WITH GRANT OPTION' at line 1
Could someone tell me how can I correct this syntax error ?
You are missing the ON object_name here in your GRANT statement like
GRANT CREATE USER ON *.* TO 'Hamza'#'localhost' WITH GRANT OPTION;

Error Code: 1044. Access denied for user

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