Mysql-忘记root密码处理
原理:修改配置文件/etc/my.cnf,在mysqld项增加skip-grant-tables,重启后跳过权限验证,登录成功后,清除root密码。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| vi /etc/my.cnf
[mysqld] skip-grant-tables
systemctl restart mysqld
mysql -u root
mysql> use mysql; mysql> update user set authentication_string='' where user='root'; mysql> quit;
systemctl restart mysqld
mysql> alter user 'root'@'localhost' identified by '2dcP2$LWpcc1'; mysql> flush privileges; mysql> quit
|
老年佛系运维 | biglovewheat@126.com