Solution One
MySQL forgets super User password solution
If MySQL is running, first kill: Killall-term mysqld.
Start MySQL:
The code is as follows |
Copy Code |
Bin/safe_mysqld--skip-grant-tables & |
You can get into MySQL without needing a password.
Then it's
The code is as follows |
Copy Code |
>use MySQL >update User Set Password=password ("New_pass") where user= "root"; >flush privileges; |
Re-kill MySQL, the normal way to start MySQL.
Workaround Two
The safest state is to operate on the console of the server and unplug the network cable.
2. To modify MySQL login settings:
# VI/ETC/MY.CNF
In the paragraph of [mysqld], add a sentence: Skip-grant-tables
For example:
The code is as follows |
Copy Code |
[Mysqld] Datadir=/var/lib/mysql Socket=/var/lib/mysql/mysql.sock Skip-grant-tables Save and Exit VI.
|
3. Reboot mysqld
The code is as follows |
Copy Code |
#/etc/init.d/mysqld Restart stopping MySQL: [OK] Starting MySQL: [OK]
|
4. Log in and modify the MySQL root password
code is as follows |
copy code |
#/usr/bin/mysql Welcome to the MySQL monitor. Commands End With; or G. Your MySQL Connection ID is 3 to server version:3.23.56 Type ' help. Type ' C ' to clear the buffer. mysql> use MySQL; Reading table information for completion of table and column names You can turn off this feature to get a Quicke R startup with-a Database changed mysql> UPDATE user SET Password = Password (' New-password ') WHERE user = ' Root '; Query OK, 0 rows Affected (0.00 sec) Rows matched:2 changed:0 warnings:0 mysql> flush; privileges r> Query OK, 0 rows affected (0.01 sec) Mysql> quit Bye |
5. Change the MySQL login settings back
The code is as follows |
Copy Code |
# VI/ETC/MY.CNF
|
Delete the skip-grant-tables that you just added in the [mysqld] section
Save and Exit VI.
6. Reboot mysqld
The code is as follows |
Copy Code |
#/etc/init.d/mysqld Restart stopping MySQL: [OK] Starting MySQL: [OK] |
Method III, using phpMyAdmin to modify
Recovery method:
By running the Mysqld_safe Start command, skip the account password check, so no account, password can log in the database, so you can reset the MySQL database root super account, password.
The demo is as follows:
First, with putty and other SSH tools, landing server, running
01
The code is as follows |
Copy Code |
./etc/init.d/mysqld Stop Service Mysqld Stop |
To stop MySQL,
Next, run
/usr/bin/mysqld_safe--skip-grant-tables
Start MySQL so that you can skip permission checking after running. No account, password can be logged into the database, the following figure:
Finally, enter the MySQL library user table, modify the database root Super account password, as shown below;
Note that in the Edit root page, password The function of this line to select the encryption method.
After modification, reboot the server