What should I do if I forget my MySQL password? MySQL root Password Reset method, mysqlroot

Source: Internet
Author: User

What should I do if I forget my MySQL password? MySQL root Password Reset method, mysqlroot

MySQL sometimes forgets the root password. Here we provide a password reset method for Windows and Linux.

Windows:

1. log on to the system as a system administrator.

2. Open cmd ----- net start to check whether mysql is started. If it is enabled, the net stop mysql will be stopped.

3. Install mysql in d: \ usr \ local \ mysql4 \ bin.

4. Skip the permission check and start mysql.

D: \ usr \ local \ mysql \ bin \ mysqld-nt -- skip-grant-tables

5. Open cmd again. Enter d: \ usr \ local \ mysql4 \ bin:

D: \ usr \ local \ mysql \ bin \ mysqladmin-u root flush-privileges password "newpassword"

D: \ usr \ local \ mysql \ bin \ mysqladmin-u root-p shutdown prompts you to re-enter the password.

6. net start mysql in cmd

7. You have done it.

Linux:

One of the methods to restore the MySQL root Password

If you forget the MySQL root Password, use the following method to reset it:

1. KILL the MySQL process in the system;
Killall-TERM MySQLd

2. Run the following command to start MySQL without checking its permissions;
Safe_MySQLd -- skip-grant-tables &

3. Use the empty password to log on to MySQL as the root user;
MySQL-u root

4. Modify the password of the root user;
MySQL> update MySQL. user set password = PASSWORD ('new password') where User = 'root ';
MySQL> flush privileges;
MySQL> quit

Restart MySQL to log on with the new password.

MySQLroot password restoration method 2

It is possible that your system does not have the safe_MySQLd Program (for example, I am using the ubuntu operating system, MySQL installed with apt-get). The following method can be restored:

1. Stop MySQLd;
Sudo/etc/init. d/MySQL stop
(You may have other methods. Simply stop running MySQLd)

2. Run the following command to start MySQL without checking its permissions;
MySQLd -- skip-grant-tables &

3. Use the empty password to log on to MySQL as the root user;
MySQL-u root

4. Modify the password of the root user;
MySQL> update MySQL. user set password = PASSWORD ('newpassword') where User = 'root ';
MySQL> flush privileges;
MySQL> quit

Restart MySQL
/Etc/init. d/MySQL restart
You can use the new password newpassword to log on.

The above describes how to reset the root password of MySQL. I hope you can learn more about MySQL syntax and follow MySQL 5.1 reference manual.

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.