1.修改配置文件

vim /etc/my.cnf

在[mysqld]节点添加

skip-grant-tables

2.重启mysql

3.用空密码进入

mysql -uroot

执行

update mysql.user set authentication_string=password('123') where user='root' and Host = 'localhost';

 flush privileges;

退出mysql

还原my.cnf

补充,使用上面方法修改密码后,在使用mysql -uroot -p < demo.sql导入数据时候报错,所以用如下语句修改密码更好

ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass';

相关文章:

  • 2021-09-09
  • 2021-11-21
  • 2022-12-23
  • 2021-08-15
  • 2022-01-15
  • 2021-10-14
  • 2021-05-27
  • 2021-06-07
猜你喜欢
  • 2021-09-21
  • 2022-12-23
  • 2022-02-10
  • 2021-08-01
  • 2022-12-23
相关资源
相似解决方案