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