8.0版本的user表里,没有password字段,取而代之的是authentication_string。所以需要设置密码时,应该操作此字段。
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 ‘你的密码’
参考链接:https://blog.csdn.net/qq_42833469/article/details/90674945