Method One:
1. Stop MySQL Services: Service mysqld stop
2. Start the MySQL service via Mysqld_safe and pass two parameters at the same time:
--skip-grant-tables--skip-networking
namely: Mysqld_safe--skip-grant-tables--skip-networking &
3, the empty password to connect to MySQL, namely: mysql-uroot-p
4, change the root password,
That is: Update mysql.user set Password=password (' New_password ') where condition;
5, restart the MYSL service, normal connection can be.
Method Two:
1. Stop MySQL Services: Service mysqld stop
2, VIM/ETC/MY.CNF
Added under [mysqld]: Skip-grant-tables
Skip-networking
3, save exit, empty password connection MySQL
4. Change the root password
5, edit my.cnf, remove the contents of Step 2 added, save the exit, restart the MySQL service.
This article is from "Walking in the growth, drip records ..." Blog, be sure to keep this source http://poseidon2011.blog.51cto.com/7553825/1863008
MySQL Recover admin password