1.跳过mysql密码认证
vim /etc/my.cnf #在[mysqld]后面任意一行添加“skip-grant-tables"跳过密码验证过程。
2.重启mysql
/etc/init.d/mysqld restart
3.进入到mysql并修改密码
[root@nuanfeng ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.73-log MySQL Community Server (GPL) Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> mysql> use mysql; mysql> update user set password=password('你的密码') where user='root' and host='localhost'; mysql> flush privileges;
4.删除skip-grant-tables
5.重启数据库
转载请注明:暖风 » Mysql 重置root密码