Retrieve the lost MySQL root user password

Source: Internet
Author: User

1. Stop MySQL First

/etc/init.d/mysqld stop

2. Use--skip-grant-table to start MySQL, ignoring authorization login verification.

Mysqld_safe--skip-grant-tables--user=mysql &

Mysql-u root-p <== Login time-space password.

Hint: The--skip-grant-tables parameter is added at startup to indicate that authorization table validation is ignored.


This goes in, no need for a password to enter MySQL

You can use update to change your password after you go in.

Mysql>update Mysql.user Set Password=password ("liucong456") where user= ' root ' and host= ' localhost '


Mysql>flush privileges;


Next you need to restart MySQL, remember to reboot.


Reboot is with the command

Mysqladmin-u root-p ' 456 ' shutdown


/etc/init.d/mysql start


Mysql-u root-p

You can do it.



If MySQL is not turned off, you can only

Killall Msyqld.



The following is a multi-instance MySQL boot modify lost root password method

1. Turn off MySQL

Killall Msyqld

2. Add--skip-grant-tables parameter at startup

Mysqld_safe--defaults-file=/data/3306/my.cnf--skip-grant-table &

Mysql-uroot-p-s/data/3306/mysql.sock <== Login time-space password


3. Changing the password is the same as a single instance.



Retrieve the lost MySQL root user 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.