mysql80重置密码_MySQL8.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修改用戶密碼,因為在MySQL8.0以后的加密方式為caching_sha2_password,如果使用update修改密碼會給user表中root用戶的authentication_string字段下設置newpassowrd值,當再使用alter user 'root'@'localhost' identified by 'newpassword'修改密碼時會一直報錯,必須清空后再修改,因為authentication_string字段下只能是MySQL加密后的43位字符串密碼,其他的會報格式錯誤,所以在MySQL8.0以后能修改密碼的方法只能是:ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '你的密碼';
總結
以上是生活随笔為你收集整理的mysql80重置密码_MySQL8.0修改密码问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 漫步者皮纹版 M230 蓝牙音箱上架,售
- 下一篇: mysql在线快速修改密码_MySQL修