Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL 8 create new user with password not working

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.

like image 639
Akshay Pethani Avatar asked May 18 '18 10:05

Akshay Pethani


People also ask

What is the correct way to create a user with a password in MySQL?

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.

How do I start MySQL username and password?

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.

What is the datatype for password in MySQL?

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.


1 Answers

Try this:

use mysql; CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; GRANT ALL ON *.* TO 'username'@'localhost'; flush privileges; 
like image 141
Delete Avatar answered Sep 19 '22 17:09

Delete