MySQL forgot password

Source: Internet
Author: User

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 ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.