MYSQL 5.7 for Windows reset root password

Source: Internet
Author: User

Original: https://dev.mysql.com/doc/mysql-windows-excerpt/5.7/en/resetting-permissions-windows.html

1. Stop the MySQL service, if MySQL is installed in the Windows service, stop in Service Manager, and if it is running on the command line, you will need to force the process to stop in Task Manager.

2. Create a script to start MySQL load execution when the script content is to change the root password:

MySQL 5.7.6 and later versions:

ALTER USER ' root ' @ ' localhost ' identified by ' mynewpass ';

MySQL 5.7.5 and Previous versions:

SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' Mynewpass ');

将文件保存在某路径,例如D:/init.sql

3. 需要进入到mysql的安装目录下的bin目录,其中包含了mysql的daemon程序“mysqld.exe”,在这个目录运行命令行(文件管理器shift+鼠标右键-在此处打开命令行窗口),输入命令:

Mysqld--init-file=d:/init.sql

Ensure that the MySQL service starts properly by looking in the process manager for a process that has no MySQL, if the path of the script is specified incorrectly, or if there is a problem in the script that causes the startup to fail. If successful startup, the root password should be modified.

If alter user modifies the password statement to fail, attempt to modify the user table directly using the following statement:

UPDATE mysql.user SET authentication_string = PASSWORD (' Mynewpass '), password_expired = ' N ' WHERE user = ' root ' and Host = ' localhost '; FLUSH privileges;

4. After completion, start the MySQL service using normal boot mode, no longer use the--init-file parameter

MYSQL 5.7 for Windows reset root password

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.