修改MySQL密码时出现ERROR 1064 (42000)解决方法

1.进入MySQL的bin目录,输入mysql -u root -p

E:\jieyapackage\mysql-8.0.22-winx64\bin>mysql -u root -p
Enter password: ***********
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.22 MySQL Community Server - GPL

2.输入 set password for root@localhost = password(‘123456’);出现报错:您的SQL语法有错误;请查看MySQL服务器版本对应的手册,在第1行的“password(‘123456’)”附近使用正确的语法。

mysql>  set password for root@localhost = password('123456');
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 'password('123456')' at line 1

3.输入set password for root@localhost = password(‘123456’);即可解决

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.15 sec)

你可能感兴趣的:(mysql)