Reset the root password of MySQL in CentOS

Source: Internet
Author: User
Tags mysql client
Yesterday I forgot the password of the root user of the mysql database on a server. after searching and solving the problem, I learned that I could reset the root password as follows: 1. stop the mysql service # if there is a service, stop it like this # servicemysqldstop2. when starting the mysql service, add the ignore authorization option # mysqld_safe -- skip-grant-tables & amp; 3. use the mysql client to directly connect to the console # mys

Yesterday I forgot the password of the root user of the mysql database on a server. after searching and solving the problem, I learned that I could reset the root password as follows:

1. stop the mysql service

 
 
  1. # If there is a service, you can stop it like this
  2. # Service mysqld stop

2. add the ignore authorization option when starting the mysql service

 
 
  1. # mysqld_safe --skip-grant-tables &

3. use the mysql client to directly connect to the console

 
 
  1. # mysql

4. change the root account password on the mysql console

 
 
  1. mysql>use mysql;
  2. mysql>update user setpassword=password('root') where name='root' and host='localhost';
  3. mysql>\q

5. stop the mysql service and kill the mysql process.

6. start the mysql service in normal mode.

 
 
  1. # service mysqld start

Then, connect to the mysql client and enter the root password. in step 3, the root password has been reset to root. In fact, it's quite simple. well, record it for future reference.


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.