Summary of root password recovery method in MySQL database

Source: Internet
Author: User
Tags flush mysql mysql database
Summary of root password recovery method in MySQL database

Method One

1. Download MySQL source distribution, do not differentiate the operating system, we need something is the same;


2. Rename your MySQL folder under the data directory for Oldmysql;

3. Copy the MySQL directory under the data directory in the source package to your MySQL data directory;

4. Restart MySQL, now the MySQL licensing relationship with the new installation of the same, empty password landing, and then adjust their authorization;

5. Open Oldmysql This library to check what happened to the problem;

6. If there is a backup of the system in the central database integrity testing to avoid being modified.

Method Two

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.

Kill ' Cat/mysql-data-directory/hostname.pid '

You must be the root user of Linux or an equivalent user on the server you are running to perform this operation;

Killall-term mysqld

2. Use '--skip-grant-tables ' parameter to start mysqld;

Shell>mysqld_safe--skip-grant-tables &

/Bin/safe_mysqld--skip-grant-tables &


3. Use the ' mysql-h hostname mysql ' command to log on to the MYSQLD server and change the password with the grant command. You can also do this:

' Mysqladmin-h hostname-u user password ' new password '

Actually, you can use

Use MySQL; Update user Set Password =password (' Yourpass ') where user= ' root '

To do;

Shell>mysqladmin-u root flush-privileges password "NewPassword"

>use MySQL

>update User Set Password=password ("New_pass") where user= "root";

>flush privileges;

4. Loading permission table:

`

mysqladmin-h hostname flush-privileges '

or use SQL commands

' FLUSH privileges '

Of course, here, you can also restart mysqld.



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.