MySQL Forgot password modification method detailed

Source: Internet
Author: User
Tags flush

Long time no use of the database, it is inevitable that the password to forget the database, if the MySQL database password forgot how to do? Here are two simple ways to reset your password!

How to reset a password under Windows system

If you are the server is Windows Xp/2000/2003/nt can use this method to retrieve the missing MySQL super Administrator root password

1, stop the MySQL service, CMD Open the DOS window, input net stop MySQL


2, in the CMD Command Line window, enter the MySQL installation directory such as d:mysql20080505in

3, enter the MySQL security mode, that is, when MySQL up, do not enter the password can enter the database.
Command is: Mysqld-nt--skip-grant-tables

***************************************
4, reopen a CMD command line window, enter mysql-uroot-p, use the way of NULL password login mysql (do not enter the password, directly press ENTER)


5, enter the following command to begin modifying the root user's password (note: there is a "dot" in the Mysql.user in the command)
mysql> Update Mysql.user Set Password=password ("New password") where user= "root";

6, Refresh the permission table

mysql> flush Privileges;


7, exit
Mysql> quit

This MySQL Super Administrator account root has been reset, then in the Task Manager to end the process of Mysql-nt.exe, restart MySQL! (You can also restart the server directly)

Solutions under the Unix&linux system:

1. User login system with root or running mysqld;

2. Use the KILL command to end the process of mysqld. (You can open the command line and then run the Ps-ef | grep MySQL "To view the MySQL process ID and then use" kill-9 MySQL process id "to kill the process.

3. Start MySQL Server with the –skip-grant-tables parameter

Shell>mysqld--skip-grant-tables

4. Set a new password for root@localhost

Use MySQL;
Update user SET Password=password (' New password ') where user= ' root ';
Flush privileges;

5. Restart MySQL Server, Setup complete.

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.