修改mysql的root密码

以前修改mysql的root密码的语句为:

set password for root@localhost=password('root');

但是,这样的语句,已经不能执行了,直接报错。原因是:现行的mysql,没有password字段了,也没有password()语句了。
详细的报错信息为:

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('root')' at line 1

在此正确的修改mysql的root密码方式应该为:

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

你可能感兴趣的:(修改mysql的root密码)