mysql5.7.9版本之后的user表中取消了password这个字段,改成了authentication_string
所以用update user set password=password(“123”) where user="root"
或者 set password for [email protected] = password(‘123’) 等含有password的命令都会报1064语法错误,试过在navicat里直接改也会报1064语法错误(也许是我版本不匹配?)
如图↓
【mysql】mysql8.0进入mysql后修改密码
【mysql】mysql8.0进入mysql后修改密码
正确的做法是:

  1. 进入mysql
  2. 切换数据库
    输入use mysql
    【mysql】mysql8.0进入mysql后修改密码
  3. 查看user表的信息(查看要修改的user对应的host,不一定是localhost)
    输入select user,host from user; (别忘了打 ; 分号)
    【mysql】mysql8.0进入mysql后修改密码
  4. 修改密码
    输入alter user ‘你的user名’@‘你的host’ identified with mysql_native_password by “新密码”;
    比如:alter user ‘root’@‘localhost’ identified with mysql_native_password by “123”;
    修改成功

相关文章:

  • 2022-01-04
  • 2021-10-24
  • 2021-12-01
  • 2021-04-02
  • 2021-11-14
猜你喜欢
  • 2021-10-20
  • 2021-10-08
  • 2022-01-05
  • 2021-05-01
  • 2022-01-08
  • 2021-05-08
相关资源
相似解决方案