What should I do if I forget my password in MySQL? _ MySQL

Source: Internet
Author: User
What if MySQL forgets its password? bitsCN.com

Time: 2014.01.19

Location: Base

Bytes ----------------------------------------------------------------------------------------

I. Background

Wow, when I debugged the code this evening, I found that the MySQL database could not be opened because of a wrong password. I used it well and didn't know how to change the password. why, after a long time, I finally solved the problem. ,

My system environment: Win7 + MySQL 5.6

Bytes ----------------------------------------------------------------------------------------

2. Solution steps

0. my MySQ installation path is: D:/Program Files/MySQL

1. switch to the disk in cmd first.

Input-> D:

Enter-> cd "D:/Program Files/MySQL Server 5.6/bin", pay attention to double quotation marks, so that we can switch to the MySQL installation directory.

2. start MySQL in safe mode, that is, do not enter the password to enter the database

Enter-> mysqld-nt -- skip-grant-tables. note the space between the parameters and the marker after the two bars. This step is very important.

3. re-open a cmd window and follow the preceding steps to open the MySQL installation directory and run MySQL

Input-> d:

Input-> cd "D:/Program Files/MySQL Server 5.6/bin"

Input-> D:/Program Files/MySQL Server 5.6/bin> mysql-uroot-p

Tip-> Enter password:

Press space

4. force modify the root user password

Enter-> update mysql. user set password = PASSWORD ('New password') where User = 'root'; note that there is a dot between mysql and user. because mysql has been started, add a semicolon at the end of the statement.

5. refresh permissions

Enter-> flush privileges;

----------------------------------------------------------

III. postscript

Friend, if you happen to encounter this problem and find it again, please feel free to follow the above steps. you will succeed!

BitsCN.com

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.