Today get a server, want to deploy the project, the results found that MySQL has been installed, while the password forgotten. Tragedy, the original was not apt-get installed, resulting in the deletion will not clean.
There is no way, only to retrieve the password.
Prerequisite: root password is necessary.
First step: Modify the MySQL configuration
vim/etc/mysql/my.cnf //Modify the backup before one AH.
Under the [Mysqld] module, add a line:skip-grant-tables //So that root does not require a password to enter
Step two: Go to MySQL
Service MySQL restart//restart
MySQL//Then you can go directly into the
Step three: Modify the user table of the MySQL database
Use MySQL;
Update mysql.user set Password=password (' New password ') where user= "test"; //can also add and host= "localhost", only modify local link password
flush privileges; The password has been modified successfully
Quit
Fourth step: Turn off Skip-grant-tables mode
Similar to the first step, delete the line and restart MySQL. But you can not forget the database is very dangerous oh ~