What should I do if I forget the root password of MySQL? How to reset the MySQL password

Source: Internet
Author: User

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 content is an introduction to the solution to the problem of forgetting the MySQL root password. I hope you will gain some benefits.

From: http://it.oyksoft.com/post/6438/

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.