mysql修改root密码报错1396_MySQL8.0修改密码问题

论坛 期权论坛 编程之家     
选择匿名的用户   2021-5-21 13:59   25   0

MySQL5.7和之前的用户修改密码方式:mysql -uroot -e "Set password=password(‘123’);"

mysql -uroot -p123.com -e "use mysql;update user set authentication_string=password('456') where user='root';"

update mysql.user set authentication_string=password("123") where user='root';

以上三种方法在MySQL8.0以后版本中将不能使用,如果使用了将会导致在正确修改密码是报如下错误:mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';

ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'

如遇上以上问题请使用update语句先清空authentication_string字段,然后再修改密码即可update user set authentication_string='' where user='root';

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密码';

所以特别提醒童鞋们:

MySQL8.0后请使用alter修改用户密码

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP