MySQL5.7已经没有password这个字段了,改成了authentication_string

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

完整的更改MySQL密码的方式如下:

1.vim /etc/my.cnf [mysqld]段增加skip-grant-tables

2./etc/init.d/mysqld restart

3.终端输入mysql 直接登录MySQL数据库,然后use mysql

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

5.flush privileges;  #立即生效

6.quit;

7.编辑/etc/my.cnf 删掉skip-grant-tables, 然后重启MySQL /etc/init.d/mysqld restart

8.mysql -u root -p 然后输入密码即可登录MySQL数据库

 

旧版改密码的命令如下,MySQL5.7 password改成了authentication_string

mysql> update user set password=password(“新密码”) where user=”用户名”;

相关文章:

  • 2022-12-23
  • 2021-11-09
  • 2021-04-05
猜你喜欢
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2021-06-23
  • 2022-02-12
  • 2022-12-23
相关资源
相似解决方案