Monday, March 30, 2020

Grant command changed in MySQL 8

The below command no longer working in MySQL 8.x

msql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost" IDENTIFIED BY "password";
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 "password"' at line 1

It seems that MySQL no longer support the one liner version of grant command, it's now requires to create user first and the grant the privileges

mySQL> CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'word123';
Query OK, 0 rows affected (0.01 sec)

mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost";

No comments:

Post a Comment