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.
mysql> CREATE USER 'local_user'@'localhost' IDENTIFIED BY 'password'; This command will allow the user with username local_user to access the MySQL instance from the local machine (localhost) and prevent the user from accessing it directly from any other machine.
Replace [username] with the username for your MySQL installation. Enter mysql.exe -uroot -p , and MySQL will launch using the root user. MySQL will prompt you for your password. Enter the password from the user account you specified with the –u tag, and you'll connect to the MySQL server.
MySQL PASSWORD() function MySQL password() returns a binary string from a plain text password. The function returns NULL if the string supplied as the argument was NULL.
Try this:
use mysql; CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL ON *.* TO 'username'@'localhost'; flush privileges;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With