Several ways to recover MySQL password under Linux

Source: Internet
Author: User

today we are mainly talking about Linux forget MySQL Password processing method, the following provides 5 kinds of Linux forgot MySQL password recovery method Oh.
Method One (Enter root permission first):

#/etc/init.d/mysql Stop
# Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
# mysql-u Root
mysql> Update user Set Password=password ("NewPassword") where user= ' root ';
mysql> flush Privileges;
Mysql> quit
#/etc/init.d/mysql Restart
# mysql-uroot-p
Enter Password: < Enter the newly set password newpassword>
Mysql>
Method Two:
Use the user name and password provided directly in the [client] section of the/etc/mysql/debian.cnf file:
# mysql-udebian-sys-maint-p
Enter Password: < Enter the password for the [client] section >
mysql> Update user Set Password=password ("NewPassword") where user=root;
mysql> flush Privileges;
Mysql> quit
# mysql-uroot-p
Enter Password: < Enter the newly set password newpassword>
Mysql>
Method Three:
This method I have not been tested, because my root user default password has been modified by me, the person has time to test, the results told me, thank you!!
# mysql-uroot-p
Enter Password: < Enter the password provided in the [Client] section of the/etc/mysql/debian.cnf file >
method Four:
The method is as follows: 1, turn off the MySQL service/etc/init.d/mysqld stop 2, start the MySQL service with the –skip-grant-tables option, you can modify the/etc/inin.d/mysqld script start location to increase this option, VI/ Etc/init.d/mysqld
Here's how:
1. Turn off MySQL service
/etc/init.d/mysqld stop
2, using the –skip-grant-tables option to start the MySQL service, you can modify the/etc/inin.d/mysqld script start location to increase this option,
Vi/etc/init.d/mysqld
Add--skip-grant-tables in the statement below to run the start
/usr/bin/mysqld_safe--skip-grant-tables--datadir= "$datadir"--socket= "$socketfile"
--log-error= "$errlogfile"--pid-file= "$mypidfile"
Joining--skip-grant-tables means skipping permission table authentication when starting the MySQL service. After booting, the root of the connection to MySQL does not require a password
3. Restart the MySQL service
/etc/init.d/mysqld start
4. Change the password of the root user;
mysql> Update Mysql.user Set Password=password ("123456") where user=root;
mysql> flush Privileges;
Mysql> quit
5. Restart MySQL to log in with the new password.
Mysql
Mysql-u root–p
Enter Password: 123456
6. Turn off MySQL service
/etc/init.d/mysqld stop
7, re-modify the 2nd step of the/etc/init.d/mysqld, so that it remains the same, that is, cancel the--skip-grant-tables statement
8. Restart the MySQL service
/etc/init.d/mysqld start

Postscript:

The new installation of MySQL is password, but in fact automatically stored in a folder, I installed the mysql-server-5.6.35-1.el6.x86_64.rpm,rpm installation mode, the root password of MySQL, the default password exists:/root/. Mysql_secret in this folder./////But I just can't open it. So: Just forget the password and how to retrieve the initial root password of MySQL. The methods found are feasible, but the only downside is that the new password needs to be in double quotes when the NEWPASSWD is set, and the original blogger does not. So turn around and use it.

Attached to the original address:

Https://www.2cto.com/os/201104/86881.html

Several ways to recover MySQL password under Linux

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.