How can I reset the Mysql root Password in the Window? mysqlroot

Source: Internet
Author: User

How can I reset the Mysql root Password in the Window? mysqlroot

My machine environment:

Windows 2008 R2

For MySQL 5.6

Using "Windows forgot Mysql root Password" Baidu, I found a lot of solutions. Most of them are similar. The classic one is the article [1] on Baidu Library, which is illustrated in images and clear. Follow the instructions described in this article.

The procedure is as follows:

If you have added an environment variable for MySQL, you can directly run the mysql Command. Otherwise, you must go to the bin directory of the mysql installation directory.

The procedure is as follows:

1. stop the mysql Service (run as an administrator on the cmd Command Line). net stop mysql

2. Run the mysqld-skip-grant-tables command to start the mysql database.

D: \> net stop mysql MySQL service is being stopped. MySQL service has been stopped successfully.

D: \> mysqld -- skip-grant-tables

3. Do not close the above window. Open a new cmd window, enter mysql-u root, and press Enter.

D: \> mysql-u root

Welcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 1 Server version: 5.1.26-rc-community MySQL Community Server (GPL) Type 'help; 'or' \ H' for help. type '\ C' to clear the buffer.

Mysql> update mysql. user set password = password ('aaa') where user = 'root ';

You can write the password on your own.

Query OK, 1 row affected (0.02 sec) Rows matched: 2 Changed: 1 Warnings: 0

Mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec) mysql>

4. Open the task manager, stop the mysql and mysqld processes, and start the mysqld service using net start mysql. Then, you can use the root password of the root user to enter the database.

Mysql-u root-p aaa

Note:

1. Use the following command to view the usage instructions of mysqld:

Mysqld -- verbose -- help> d: \ mysqld_help.txt

Help-skip-grant-tables:

-- Skip-grant-tables Start without grant tables. This gives all users full access to all tables!

Therefore, you can use mysql-uroot to directly log on to mysql without a password, and you can modify any table.

In my practice, start mysql with mysqld -- skip-grant-tables. mysql-u root-p can log on with a blank password. If you change the password, a message is displayed, but when mysql is started normally, you cannot log on with a new password. I think that since I cannot find the answer on a Chinese website, I try to ask for the answer on a foreign website. The keyword "B .5.3.2 How to Reset the root password" [2] was found in the document "B .5.3.2 How to Reset the Root Password" on mysql.com.

The procedure is as follows:

(1) Stop mysql

If it runs as a service, stop the mysql service in the service management tool. Or run the following command on the console.

Net stop mysql56

If the process is not running as a service, terminate the mysqld process in the task manager.

(2) create a text file and write the following content. MyNewPass is the new password.

Set password for 'root' @ 'localhost' = PASSWORD ('mynewpass ');

(3) Save as c: \ init.txt

(4) execute the following command in the console window:

Mysqld -- init-file = C :\\ init. ini

Note:

1) if the MySQL environment variable is added, you can directly run mysql-related commands. Otherwise, you must operate in the bin directory of the mysql installation directory.

2) if you are using the Mysql Installation Wizard to install Mysql, you need to add the -- defaults-file parameter. The command is as follows:

Mysqld -- defaults-file = "C: \ ProgramData \ MySQL Server 5.6 \ my. ini" -- init-file = C :\\ init. ini

-- Defaults-file parameters can be obtained from service management: Start Control Panel management tools service, find MySql Service, right-click it, and select the Properties tab, the "execution path" contains the -- defaults-file parameter.

(5) After the system starts successfully, close Mysql and delete the init. ini file.

References:

[1] http://wenku.baidu.com/view/5c0d2164e55c3b3567ec102de2bd960590c6d9c0

[2] https://dev.mysql.com/doc/refman/5.6/en/resetting-permissions.html

The above section describes how to reset the Mysql root Password in windows. I hope it will be helpful to you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.