1、停止mysql服务

service mysql stop

2、启动mysql时不启动授权表,跳过权限验证使用空密码登陆

mysqld_safe --skip-grant-tables &

3、登陆mysql

mysql -uroot -p

4、设置mysql的root用户密码为123456

update mysql.user set password=password("123456") where user="root";

5、强制mysql重新加载权限

flush privileges;

6、退出及重启mysql

exit
service mysql restart

7、登陆mysql

mysql -uroot -p123456

8、重设root密码 

此时执行任何mysql命令会报如下错误 ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

set password=password('123456');

 

相关文章:

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