1、修改my.conf配置文件,添加 skip-grant-tables ,保存并退出,systenctl restart mysqld.service 命令重启服务
2、登陆mysql数据库(直接输入mysql即可),修改登陆用户的密码alter user [email protected](如 [email protected]) identified by “new_password”;
或 update mysql.user set authentication_string=password(“NewPassword”) where user=”root”;
3、使用 flush privileges ; 写入命令
注:执行完步骤“2”会报错“ERROR 1290 (HY000): The MySQL server is running with the –skip-grant-tables option so it cannot execute this statement” ,直接忽略执行步骤3即可
4、修改my.conf配置文件,去掉 skip-grant-tables 并重新启动mysqld服务
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/tech/database/3859.html