MySQL Reset root password

Source: Internet
Author: User

A How to reset the root password after forgetting the root password of MySQL

1. Edit the MySQL configuration file:
In the Windows environment:%mysql_installdir%\my.ini//mysql The My.ini configuration file under the installation directory.
Linux Environment:/ETC/MY.CNF
Add the following line to the [MySQLd] configuration segment: Skip-grant-tables
Save to exit Edit.

2. Then restart the MySQL service
In the Windows environment:
net stop MySQL
net start MySQL
In a Linux environment:
/etc/init.d/mysqld restart

3. Set a new root password
Then execute it under the cmd command line:
Mysql-uroot-p MySQL
When you require a password, enter the database directly without a password.
Now we execute the following statement to update the root password to 123456:
Update user set Password=password ("123456") where user= ' root '
Quit MySQL.

4. Restore the configuration file and restart the service
Then modify the MySQL configuration file to delete the line you just added (skip-grant-tables).
Restart the MySQL service again to

Two Modify the MySQL username and password: (not confirmed)

Method One: (for Administrators or users with global permissions to reset other user's password)
Enter command line mode
Mysql-u Root MySQL
mysql> UPDATE user SET Password=password ("New password") WHERE user= ' name '
Mysql> FLUSH Privileges
Mysql> QUIT
Method Two: (Apply ibid., only method is different)
Mysql-u Root MySQL
Mysql> SET PASSWORD for Name=password (' New PASSWORD ')
Mysql> QUIT
The last must kill skill:
mysqladmin-u root "Old password" "New password"
Note: Please use your username to replace the above name, new password Please enter the password you want to set.

MySQL 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.