Linux forgot MySQL password retrieve method

Source: Internet
Author: User
Tags flush mysql tutorial

Linux Forget MySQL tutorial password retrieve method
Today we mainly talk about Linux forget MySQL password processing method, below provides 5 kinds of Linux forget MySQL password to retrieve the method oh.
Method One:

#/etc/init.d/mysql Stop
# Mysqld_safe--user=mysql--skip-grant-tables--skip-networking &
# mysql-u Root MySQL
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 new password newpassword>
Mysql>

Method Two:
Use the username 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 [client] section >
mysql> Update user Set Password=password (' NewPassword ') where user= ' root ';
mysql> flush Privileges;
Mysql> quit
# mysql-uroot-p
Enter Password: < Enter the new password newpassword>
Mysql>

Method Three:
This method I did not have to test, because my root user default password has been modified by me, that a free test, tell me the results, thank you!!

# Mysql-uroot-p
Enter Password: < Enter the password provided in the [Client] section of/ETC/MYSQL/DEBIAN.CNF file >


Method Four

The method is as follows: 1, turn off the MySQL service/etc/init.d/mysqld stop 2, use the –skip-grant-tables option to start the MySQL service, you can modify the/etc/inin.d/mysqld script startup location to add this option, VI/ Etc/init.d/mysqld
The method is as follows:

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 startup location to add this option,
Vi/etc/init.d/mysqld

Add--skip-grant-tables in the following statement to run the startup
/usr/bin/mysqld_safe--skip-grant-tables--datadir= "$datadir"--socket= "$socketfile"
--log-error= "$errlogfile"--pid-file= "$mypidfile"

Adding--skip-grant-tables means skipping permission table authentication when you start 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 root user;

mysql> Update Mysql.user Set Password=password (' 123456 ') where user=root;
mysql> flush Privileges;
Mysql> quit

5. Restart MySQL, you can 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, modify the 2nd step of the modified/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
Unix

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.