MySQL database forgot password "reprint"

Source: Internet
Author: User

In the Windows environment

1. Kill all the MySQL processes

A. Through DOS command: NET start and net stop MySQL

B. Services through the Control Panel

2. In the DOS prompt box, locate the path to the MySQL installation directory such as: C:\mysql\bin

In console input: mysqld--skip-grant-tables//over root permissions

After the carriage return, there is no display, indicating success

3. Reopen a DOS prompt box, enter mysql-u root-p in the box to login without password

4. Modify the MySQL password

Enter the following command

>use MySQL

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

>flush privileges;

You can also do this: mysqladmin-h hostname-u user password ' new password '.

In the load permissions ' mysqladmin-h hostname flush-privileges ', or use the SQL command ' flush privileges '.

5. Exit

Input \q

6. Re-enter MySQL with the newly modified password



Under the Linux environment:

1. Terminal input VI/ETC/MY.CNF

Enter to change, add in [MYSQLD] Paragraph

Skip-grant-tables Save exit

2. Restart the MySQL service

Service mysqld Restart

3. Log in to MySQL

Terminal input: MySQL Enter login

After entering MySQL, enter:

Use MySQL;

Update user set Password=password (' New password ') where user= ' root ';

Flush privileges;

Quit

Quit MySQL

4. Enter vi/etc/my.cnf again

Change back to the original state, remove Skip-grant-tables, save exit

5. Restart the MySQL service

Service mysqld Restart, login with new password

Reprint url:http://mrhouzhibin.blog.163.com/blog/static/1945962412011926112959446/

MySQL database forgot password "reprint"

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.