Kolin Huang
Kolin Huang

Reputation: 95

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.

Upvotes: 6

Views: 29288

Answers (2)

Gryu
Gryu

Reputation: 2189

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

Upvotes: 6

Windsting
Windsting

Reputation: 735

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

Unsuccessfully granting privileges

Upvotes: 3

Related Questions