MySQL root Password Loss Resolution summary

Source: Internet
Author: User

1. Check the my.cnf to see if there is a password ... That's one of those, isn't it?

2. If you can restart,
First use the –skip-grant-tables parameter restart, and then change the password, and then remove the –skip-grant-tables parameter restart, pay attention to –skip-grant-tables security problems http://code.openark.org/ Blog/mysql/dangers-of-skip-grant-tables, according to the Fire Ding notes http://huoding.com/2011/06/12/85, also need to add--skip-networking

$ mysqld_safe--skip-grant-tables--skip-networking &
After using the SQL Reset password, remember to remove the skip-networking and restart the MySQL service in the normal way:

$/etc/init.d/mysqld Restart
The above method needs to restart the service two times, in fact, it can be more elegant, reboot once: the first need to save the SQL statement used in a text file (/path/to/init/file):

UPDATE mysql.user SET password=password (' ... ') WHERE user= ' ... ' and host= ' ... ';
FLUSH privileges;
Then use the Init-file parameter to start the MySQL service,

$/etc/init.d/mysql Stop
$ mysqld_safe--init-file=/path/to/init/file &
At this point, the password has been reset, and finally do not forget to delete the contents of the file, so as not to disclose the password.

3.on Linux/unix only

$ CD Data/mysql
$ CP-RP user. MYD Bck_user. Myd_ ' Date +%y%m%d ' CP-RP user. Myd/tmp/user. MYD
$ vi/tmp/user. MYD # (Edit the hashed passwords next to root*) Cp-rp/tmp/user. MYD user. MYD
$ sudo kill-hup ' pidof mysqld '
4.using an Init-file

4. There is also a 4th using a init-file, which leads to just one restart of the database instead of two. It also avoids the security issue involved with using Skip-grant-tables.

5. If you are in MySQL, there are too many options.
Reference

MySQL root Password Loss Resolution summary

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.