MySQL User name password forgot the workaround

Source: Internet
Author: User

Today would like to use the lab server MySQL, found that do not remember the user name password.

Here's how to fix it:

1. Ensure that the server is in a safe state, if possible, unplug the network cable ... (But I skipped this step, the amount)

2. Modify the/etc/my.cnf file

In the paragraph [mysqld], add:

Skip-grant-tables

Save exit.

3. Restart MySQL

Service MySQL Restart

(Why a lot of places are written mysqld, will error, drunk)

4. Log in to MySQL and enter MySQL directly

is not very magical, no password on the landing, because you have modified the configuration file Na Pro

5. Change the password, the user in MySQL is the system specifically to manage users of the table, note that the following password is a function, used to the back of the New-password encrypted

mysql> use MySQL;
mysql> UPDATE user SET Password = Password (' New-password ') WHERE user = ' root ';
mysql> flush Privileges;
Mysql> quit

6. Change the 2 config file and go back

7. Restart MySQL, same as Step 3

8. Mysql-uroot-p

It should be OK ~

MySQL User name password forgot the workaround

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.