An illegal shutdown resulted in a corrupt mysql data table instance being resolved

  • 2020-05-15 02:19:05
  • OfStack

The process of troubleshooting and repairing the data table:

1, visit the web page, error, connection to the database.

2. Start mysql service, uninstall and close mysql service installed by rpm

(yesterday, postfix was installed as if yum had installed mysql), netstat-anp |grep mysqld command is used to check that mysql service is not up, and mysql-uroot-p cannot connect to the server.

3. Check the error prompt:

110726 17:02:23 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110726 17:02:23 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/host' is marked as crashed and last (automatic?) repair failed
110726 17:02:23 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/host' is marked as crashed and last (automatic?) repair failed 110726 17:02:23 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
110726 17:24:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
110726 17:24:31 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.
A corrupt prompt database table was found. (. / mysql/host)

4. Fix the database table:

cd /var/lib/mysql/mysql
myisamchk -of host.MYI
- recovering (with keycache) MyISAM-table 'host.MYI'
Data records: 0
Table host.MYI was repaired successfully.

5. Start the service again, check whether the service is started, log in mysql, or fail. So check the error log again.

/usr/local/mysql/libexec/mysqld: Table './mysql/plugin' is marked as crashed and last (automatic?) repair failed
/usr/local/mysql/libexec/mysqld: Table 'plugin' is marked as crashed and last (automatic?) repair failed
110726 17:24:31 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110726 17:24:31 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/user' is marked as crashed and last (automatic?) repair failed
110726 17:24:31 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/user' is marked as crashed and last (automatic?) repair failed 110726 17:24:31 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended
110726 17:27:13 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
110726 17:27:13 [Warning] '--skip-locking' is deprecated and will be removed in a future release. Please use '--skip-external-locking' instead.

6. The./mysql/user tables were also found to be damaged.

[root@localhost mysql]# myisamchk -of user.MYI
- recovering (with keycache) MyISAM-table 'user.MYI'
Data records: 6

7. The table was repaired successfully, but the service still cannot be started. Continue to see the error log.

/usr/local/mysql/libexec/mysqld: Table './mysql/plugin' is marked as crashed and last (automatic?) repair failed
/usr/local/mysql/libexec/mysqld: Table 'plugin' is marked as crashed and last (automatic?) repair failed
110726 17:27:13 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
110726 17:27:13 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/db' is marked as crashed and last (automatic?) repair failed
110726 17:27:13 [ERROR] Fatal error: Can't open and lock privilege tables: Table './mysql/db' is marked as crashed and last (automatic?) repair failed
110726 17:27:13 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended

8. The last error is the./mysql/db table has not been fixed yet.

9. Execute the following command to repair./mysql/db

[root@localhost mysql]# myisamchk -of db.MYI
- recovering (with keycache) MyISAM-table 'db.MYI'
Data records: 0
Data records: 2

10. Finally, start mysql service.

/usr/local/mysql/bin/mysqld_safe &

11. Check to see if the service is running.

[root@localhost ~]# netstat -anp | grep mysqld
tcp0 0
0.0.0.0:3306
0.0.0.0:* LISTEN
4360/mysqld
unix 2 [ ACC ] STREAM LISTENING 14172
4360/mysqld /tmp/mysql.sock
The service is now found to be running.

Log on to mysql and try it.

[root@localhost ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 35
Server version: 5.1.55-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql >
You can log in.

13. Open the webpage and it can be accessed normally, indicating that the data table of MySQL database has been repaired successfully.


Related articles: