MySQL database several ways to change the password and forgot password processing method

Source: Internet
Author: User

First, MySQL change Password method:

1. Modify with Mysqladmin

#mysqladmin-uroot-p password ' newpass ' Enter password: note: If it is the first time to change the password, prompt enter password: Direct carriage return if it is reset password, prompt enter Passwor D: Enter the old password and return

2. Enter MySQL for password modification

mysql> set password for ' root ' @ ' 127.0.0.1 ' =password (' newpasswd '), or so:mysql> set password for ' root ' @ '% ' = Password (' newpasswd ');

3. Edit the user table using update

mysql> Update user Set Password=password (' NewPassword ') where user= ' root ' and host= ' localhost ';mysql> flush privileges; Note: Do not forget to execute the flush privileges command!

Second, MySQL forgot how to deal with the password

Description: In the case of MySQL running

1, under/ETC/MY.CNF [mysqld] Add skip-grant-tables Restart the MySQL process, restart the successful, directly execute #mysql can enter MySQL, and then modify the:mysql> use Mysqldatabase changedmysql> Update user set Password=password (' NewPassword ') where user= ' root ' and host= ' localhost '; Query OK, 1 row affected (0.01 sec) Rows matched:1 changed:1 warnings:0mysql> flush privileges; Query OK, 0 rows affected (0.05 sec) Note: Only the modified mode of update can be used, the set mode cannot be modified successfully in Skip-grant-tables mode! 2, remove the skip-grant-tables from the my.cnf, restart the MySQL process, you can use the new password to enter MySQL.

This article is from the "Knowledge System" blog, please be sure to keep this source http://linuxg.blog.51cto.com/4410110/1895967

MySQL database several ways to change the password and forgot password processing method

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.