Simply reset the root password of Mysql on the Centos Server

Source: Internet
Author: User
Tags centos server

Introduction: in linux, if you forget the MySQL root Password, is there a way to reset the new password?

The answer is yes. Here is a simple method to reset the MySQL root Password:

1. Edit MySQL configuration file my. cnf

Vi/etc/my. cnf # edit the file, find [mysqld], and add a line of skip-grant-tables below

[Mysqld]

Skip-grant-tables

: Wq! # Save and exit

Shutdown-r now # restart the system

2. log on to the MySQL console.

Mysql-uroot-p # Press enter directly. You do not need to enter the root password.

3. Modify the root password


Update mysql. user set password = password ('000000') where User = "root" and Host = "localhost ";

Flush privileges; # refresh the System Authorization Table

4. Cancel skip-grant-tables in/etc/my. cnf

Vi/etc/my. cnf: edit the file, find [mysqld], and delete the line skip-grant-tables.

: Wq! # Save and exit

5. Restart mysql

Service mysqld restart # restart mysql. At this time, the mysql root password has been changed to 123456.

6. log on to the mysql console.

Mysql-uroot-p # enter the mysql Console

123456 # enter the password

So far, this is done.


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.