I am using MySQL for several years and the command for the creating the new user till the MySQL 5.x version is as follow:
GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' IDENTIFIED BY 'password';
Recently I installed the MySQL 8. In that, this command is not working.
It is throwing following error while firing above command:
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
Is there any change of syntax in MySQL 8? What is the correct syntax for creating new user command in MySQL 8?
Note: I tried this syntax in MySQL 5.x versions. It is working correctly in that.
Try this:
use mysql;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL ON *.* TO 'username'@'localhost';
flush privileges;