Delete the wrong user table root can not even go up, and then we can understand the root password do not know, forget. Use this method to retrieve root and recreate the deleted user. Fortunately not on the line ... 1. Modify the login settings for MySQL:#vim/etc/my.cnfAdd a sentence to the paragraph in [mysqld]: skip-grant-Tables For example: [Mysqld] DataDir=/var/lib/MySQL Socket=/var/lib/mysql/Mysql.sock Skip-grant-tables Save and Exit VI. 2. Restart Mysqld#Service mysqld Restartstopping MySQL: [OK] starting MySQL: [OK]3. Log in and modify the root password of MySQL#MySQLWelcome to the MySQL Monitor. Commands End With;or\g. Your MySQL Connection ID is3 to Server version:3.23.56Type'Help ;' or '\h' forHelp. Type'\c'To clear the buffer. mysql>Use MySQL; Database changed MySQL> UPDATE user SET Password = Password ('New-password') WHERE User ='Root' ; Query OK, 0 rows affected (0.00sec) Rows matched:2changed:0 warnings:0 MySQL>flush Privileges; Query OK, 0 rows affected (0.01sec) MySQL>quit4. Change MySQL login settings back#vim/etc/my.cnfAdd the skip-grant-that you just added in the [MYSQLD] paragraphTables Delete Save and exit Vim5. Restart Mysqld#Service mysqld Restartstopping MySQL: [OK] starting MySQL: [OK]
MySQL deleted the user table, forgot root password