Linux CentOS reset MySQL tutorial

Source: Internet
Author: User

The first step

Check to make sure the MySQL is installed

# rpm-qa|grep-i MySQL

The execution effect is as follows

Step Two

To restart MySQL:

#/etc/init.d/mysqld

As follows

Because I have already opened, so with restart restart, if you do not open, directly with start

#/etc/init.d/mysqld Restart

The meaning of this sentence is to open the MySQL backend service

The execution effect is as follows

Step Three

View MySQL process and installation directory

# ps-ef|grep-i MySQL

As follows

You can see where the Mysqld_safe is installed (the blue part above):/usr/bin/

Then execute the command to stop MySQL:

/etc/init.d/mysqld stop

Fourth Step

To start MySQL in a safe manner:

#/usr/bin/mysqld_safe--skip-grant-tables >/dev/null 2>&1 &

Then execute the following statement:

#/usr/bin/mysql-u Root MySQL

Note: MySQL is the same as the Mysql_safe directory:/usr/bin/, this is through the "Ps-ef | grep-i MySQL "command to get.

When the "mysql>" prompt appears, enter:

mysql> Update user Set password = password (' Hanhan ') where user = ' root ';

Enter after the execution (refresh the MySQL system permissions related tables):

mysql> flush Privileges;

Then execute exit exit:

Mysql> exit;

After exiting, use the following command to log in to MySQL and try to succeed:

#mysql-U root-p

Enter password as prompted: root

Of course you can also follow this procedure to reset the password to any other string

Linux CentOS reset MySQL tutorial

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.