1、使用alter命令修改
ALTER USER ‘test’@’%’ IDENTIFIED WITH mysql_native_password BY ‘test’;
mysql_native_password–字段基于如下查询获取
select user,host,plugin from mysql.user;
中的plugin字段
容易出现如下报错
ERROR 1396 (HY000): Operation ALTER USER failed for ‘test’@’%’
通过
update mysql.user set authentication_string=password(‘test’) where user=‘test’;
解决,update后需要plush privileges;
2、使用set命令
SET PASSWORD FOR ‘config’@’%’ = PASSWORD(‘config’);
容易出现报错
ERROR 1133 (42000): Can’t find any matching row in the user table
通过
update mysql.user set authentication_string=password(‘test’) where user=‘test’;
解决,update后需要plush privileges;
3、常见错误
新安装的MySQL5.7,登录时提示密码错误,安装的时候并没有更改密码,后来通过免密码登录的方式更改密码,输入update mysql.user set password=password(‘root’) where user='root’时提示ERROR 1054 (42S22): Unknown column ‘password’ in ‘field list’,原来是mysql数据库下已经没有password这个字段了,password字段改成了
authentication_string
所以更改语句替换为update mysql.user set authentication_string=password(‘root’) where user=‘root’ ;即可




