MySQL Change password and forgot password how to deal with

Source: Internet
Author: User

This article summarizes:

1. Create a new user and specify a password

2. Change the password

3. Forgotten Password Solution


Create a new user and specify a password

1) [Windows | linux] Mysql-uroot-p

Enter password:******

mysql> create user ' Keyman ' @ ' 127.0.0.1 ' identified by ' Keyman ';

Mysql> Grant Usage on * * to ' Harry ' @ ' 127.0.0.1 ' identified by ' Harry ';

Mysql> exit

[Windows | linux] mysql-ukeyman-pkeyman-h127.0.0.1

Mysql> exit

[Windows | linux] mysql-uharry-pharry-h127.0.0.1

MySQL changes the password method summarized as follows

1) [Windows | linux] Mysql-uroot-p

mysql> set password for ' Keyman ' @ ' 127.0.0.1 ' = password (' keyman123 ');

mysql> flush Privileges;

The following statement can only modify its own password

mysql> Set Password = password (' keyman123 ');

2) [Windows | linux] Mysql-uroot-p

Mysql> Grant Usage on * * to ' keyman ' @ ' 127.0.0.1 ' identified by ' keyman123 ';

3) [Windows | linux] mysql-uroot-h127.0.0.1-p password "New_password"


Solutions for forgetting passwords

1) Stop MySQL Database

[Windows] net stop MySQL

[Linux] service mysqld stop

2) Start the database in a way that does not load the authorization table

[Windows | linux] add below line to My.ini or my.cnf configuration file

[Mysqld]

......................

Skip-grant-tables

......................

[Windows] net start MySQL

[Linux] service mysqld start

3) Log in to the database and change the password

[Windows | linux] mysql-uroot mysql

mysql> Update user Set Password=password (' New_password ') where user = ' root ';

mysql> flush Privileges;

Mysql> exit

4) Restart the database

[Windows | linux] remove ' skip-grant-tables ' from configuration file

[Windows] net stop MySQL

[Windows] net start MySQL

[Linux] service mysqld restart

5) Login with the new password

[Windows | linux] Mysql-uroot-pnew_password

Mysql>


The above content is for reference only, if have the mistake, hope please understanding.

This article is from the "Keyman" blog, make sure to keep this source http://keyman.blog.51cto.com/9807984/1652372

MySQL Change password and forgot password how to deal with

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.