Forgotten password MySQL recovery method

Source: Internet
Author: User

1. Send Kill command to MYSQLD server to turn off MYSQLD server (not kill-9), and the file that holds the process ID is usually in the directory where the MySQL database resides.

The code is as follows Copy Code
Killall-term mysqld

You must be a UNIX root user or an equivalent user on the server you are running to perform this operation.
2. Use '--skip-grant-tables ' parameter to start

The code is as follows Copy Code
Mysqld (Linux under/usr/bin/safe_mysqld--skip-grant-tables, Windows C:mysqlbinmysqld--skip-grant-tables)

3. Then login to mysqld Server without a password,

The code is as follows Copy Code
>use MySQL
>update User Set Password=password ("New_pass") where user= "root";
>flush privileges;

。 You can also do this: '

The code is as follows Copy Code
Mysqladmin-h hostname-u user password ' new password '.

4. Loading permission table:

The code is as follows Copy Code
' Mysqladmin-h hostname flush-privileges ', or use SQL command ' flush privileges '.
5.killall-term mysqld

6. Login with new password

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.