Linux/centos resetting the MySQL root user password

Source: Internet
Author: User
Sometimes you may forget the root password of MySQL, and the following will teach you to reset the MySQL root user password

Manually Modify

1. Stop MySQL Service

Execution:/etc/init.d/mysql stop, your machine is not necessarily/etc/init.d/mysql or/etc/init.d/mysqld.

Anyway, stop the database, kill the process number can also Ps–ef | grep MySQL and then kill-9 the MySQL process number

2. Skip verification to start MySQL

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

Note: If the location of the Mysqld_safe is not the same as above need to be modified to your, if not clear can be found with the Find command.

Find/-name Mysqld_safe

3. Reset Password

Then execute: mysql-u root MySQL

When the MySQL prompt appears, enter: Update user Set password = password (' Password to set ') where user = ' root ';

Enter after execution: flush privileges; Refreshes the MySQL system permissions related tables. Re-execution: exit; Exit.

4. Restart MySQL

Kill MySQL Process: Killall mysqld

Start Mysql:/etc/init.d/mysql Start

So that the MySQL password is reset.

If you are interested in this, please scan the QR code below for free for more details

Linux/centos resetting the MySQL root user password

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.