Reset the password of the ROOT user of the MYSQL database

Source: Internet
Author: User

1. Change the password when the ROOT user password of the MYSQL database is known:

1. In the SHELL environment, use the mysqladmin command to set: mysqladmin-u root-p password "new password" and press enter to enter the old password.

2. In the mysql> environment, use the update command to directly update the data in the user table of the mysql database:

Update mysql. user set password = password ('new password') where user = 'root ';

Flush privileges;

Note: The mysql statement should end with a semicolon (;).

3. In the mysql> environment, run the grant command to modify the permissions of the root user.

Grant all on *. * to root @ 'localhost' identified by 'new password ';

2. What should I do if I forget the password of the ROOT user of the mysql database? The method is as follows:

1. Close the currently running mysqld service program: service mysqld stop must first add mysqld as a system service)

2. Use the mysqld_saft script to do not load the authorization table in safe mode) to start the mysqld service.

/Usr/local/mysql/bin/mysqld_saft -- skip-grant-table &

3. log on to the database as a root user with an empty password and reset the password of the ROOT user.

# Mysql-u root

Mysql> Update mysql. user set password = password ('new password') where user = 'root ';

Mysql> flush privileges;


This article is from my technology blog, please be sure to keep this source http://2605658.blog.51cto.com/2595650/1298279

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.