MySQL password forget or change the password solution

Source: Internet
Author: User
Tags mysql command line

Today, when connecting to MySQL, found that always prompted to connect to localhost failed to find the reason, is the first two days the password has been illegally modified. Now do not know the root login password, and want to connect to the database, the site to find the next method, combined with their own practice, summarized as follows: 1, in the My.init file [mysqld] under the Skip-grant-tables, so the name Incredibles, is to skip the authorization verification table, directly manipulate the database 2. Restart MySQL (net start/stop mysql) 3, log in with root with a blank password in MySQL Command line client. Or, at the command line, tap the command "MySQL" (Path setting) 4, Change password mysql> use mysql;  Database changed  mysql> UPDATE user SET Password = pa ssWOrd (' root ') WHERE User = ' root ';  Query OK, 2 rows Affected (0.00 sec)   Rows Matched:2  changed:2 &NB Sp warnings:0  5. To see if the modification succeeded mysql> Select password from user  where user= ' root ';  +----------------------- --------------------+  | Password                                 nbsp;|  +-------------------------------------------+  | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |  | *81F5E21E35407D884A6CD4A731AEBFB6AF209E1B |  +-------------------------------------------+  2 rows in Set ( 0.00 SEC)   6, refresh permissions, MySQL new setup user or change password after you need flush privileges Refresh the MySQL system permission related table, otherwise there will be denied access, there is another way is to restart the MySQL server, to make the new settings take effect. and exit mysql> flush privileges;  Query OK, 0 rows Affected (0.00 sec)     mysql> exit  bye  7, in My.int, delete skip-grant-tables, restart MySQL 8, log in again, successful c:\windows\system32>mysql-uroot-p  Enter Password: * * *   Welcome to the MySQL Monitor.  commands End With; or \g.  Your MySQL connection ID is 10  server version:5.1.57-community MySQL Community server (GPL)

MySQL password forget or change the password solution

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.