Solve the Problem of forgetting the MYSQL database ROOT password on the CentOS Server

Source: Internet
Author: User
Tags centos server

Solve the Problem of forgetting the MYSQL database ROOT password on the CentOS Server

For various reasons, the lost MYSQL password or locally stored MYSQL database password may exist, and the problem is not terrible, we only need to find a proper solution to the problem. In the morning, a netizen used the LLsMP one-click package to build the VPS site environment. Some users could not find the ROOT password of the MYSQL database and could not manage the PHPMYADMIN database. This is not the time to sort out the solution, so that you can solve similar problems in the future.

1. Modify MYSQL Logon Settings

Vi/etc/my. cnf

Edit the my. cnf file and add a line of skip-grant-tables to [mysqld.

Add, And then: wq save and exit.

2. Restart MYSQLD

/Etc/init. d/mysqld restart

3. Prepare to change the MYSQL password

[Root @ localhost ~] #/Usr/bin/mysql
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.0.95 Source distribution

Copyright (c) 2000,201 1, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql> USE mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-

Database changed
Mysql> UPDATE user SET Password = password ('laozuo. org ') WHERE User = 'root ';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3 Changed: 3 Warnings: 0

Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

Mysql> quit
Bye

The red part is what we need to enter. Set the password to laozuo.org. You can define a new password or modify it later.

4. Edit the/etc/my. cnf File

Delete the added skip-grant-tables line, and save and exit.

Finally, restart MYSQLD.

/Etc/init. d/mysqld restart

After MYSQLD is restarted, We can log on to MYSQL management through PHPMYADMIN, and log on with the Reset 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.