MySQL password forgot how to do? Mysql Reset Root Password method _mysql

Source: Internet
Author: User
Tags flush

MySQL sometimes forgets the root password is a sad thing. This provides a password reset method under Windows and Linux.

Windows:

1. Log in as a system administrator.

2. Open cmd-----net start to see if MySQL starts. Stop the net stop MySQL when you start.

3. My MySQL is installed under the D:\usr\local\mysql4\bin.

4. Skip permission check to start MySQL.

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

5. Reopen cmd. Into the 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 This sentence prompts you to lose the password again.

6. In the cmd net start MySQL

7. It's done.

Linux:

One of the ways to restore MySQL root password

If you forget the MySQL root password, you can reset it in the following ways:

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

2. Use the following command to start MySQL, to do not check the permissions of the way to start;
Safe_mysqld--skip-grant-tables &

3. Then use the null password method to log in to MySQL with root user;
Mysql-u Root

4. Change the password of root user;
mysql> Update Mysql.user Set Password=password (' New password ') where user= ' root ';
mysql> flush Privileges;
Mysql> quit

Restart MySQL and you can log on with the new password.

Mysqlroot Password recovery Method two

It is possible that your system does not have SAFE_MYSQLD programs (such as I now use the Ubuntu operating system, Apt-get installed MySQL), the following methods can be restored

1. Stop mysqld;
Sudo/etc/init.d/mysql stop
(You may have other methods, in short stop the mysqld run on it)

2. Use the following command to start MySQL, to do not check the permissions of the way to start;
MySQLd--skip-grant-tables &

3. Then use the null password method to log in to MySQL with root user;
Mysql-u Root

4. Change the password of 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 log on using the new password NewPassword.

The above is MySQL reset root password method Introduction, hope to give you a reference, learn more MySQL syntax, we can pay attention to the MySQL 5.1 reference manual, but also hope that we support cloud habitat community.

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.