How to change the root password to install mysql8

mysql5.7.9After that, there is no passwordfunction, so, using the traditional password()function to change the root password, you will be prompted sql error

 

 UPDATE user SET authentication_string = password('123456') WHERE User='root';

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 '('123456') WHERE User='root'' at line 1

 

 

The correct way is to set a password:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

A prompt modified successfully, quit mysql landing again the need to enter a password just set.

 

For details, please refer to the article:

https://newsn.net/say/mysql8-password.html

Guess you like

Origin www.cnblogs.com/saysmy/p/11135369.html