Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

When I tried to grant privileges on users at mySQL, the error happened.Am I type something wrong on the command line?

mySQL Ver 8.0.16 for macos10.14 on x86_64 (MySQL Community Server - GPL).

mysql>grant all privileges on librarydb.* to 'phill'@'%' identified by '123456';
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 
'identified by '123456'' at line 1.
like image 927
Kolin Huang Avatar asked Jan 27 '23 02:01

Kolin Huang


2 Answers

The next command

mysql>grant all privileges on librarydb.* to 'phill'@'%' identified by '123456';

Should be changed to:

mysql> create user 'phill' identified by '123456';
mysql> grant all privileges on librarydb.* to 'phill';

if the 'phill' user have not been created yet. If it have been created earlier, then use alter instead of create

like image 52
Gryu Avatar answered Jan 31 '23 04:01

Gryu


What version is your MySQL? If it's 5.7 or later, maybe same as this question:

Unsuccessfully granting privileges

like image 30
Windsting Avatar answered Jan 31 '23 05:01

Windsting