暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

mysql5.7修改密码方法以及常见报错处理

刘群 2024-09-04
134

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’ ;即可

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论