Solve the Problem of mysql Data Table corruption caused by an illegal Shutdown

Source: Internet
Author: User
Tags localhost mysql

Troubleshooting of data tables:

1. When you access the webpage, an error is displayed, indicating that the database cannot be connected.

2. Start the mysql service and uninstall and disable the mysql service installed by rpm.

(Install postfix yesterday as if mysql is installed in yum.) run the netstat-anp | grep mysqld command to check if the mysql service is unavailable. mysql-uroot-p cannot connect to the server.

3. view the error message:

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 ure release. Please use '-- skip-external-locking' instead.
The database table is damaged. (./Mysql/host)

4. Restore database tables:

Cd/var/lib/mysql
Myisamchk-of host. MYI
-Recovering (with keycache) MyISAM-table 'host. myi'
Data records: 0
The host. MYI table is successfully repaired.

5. Start the service again, check whether the service is started, and log on to mysql. 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 ure release. Please use '-- skip-external-locking' instead.

6. The./mysql/user table is damaged.

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

7. The table is successfully repaired, but the service cannot be started. continue to view 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 that the./mysql/db table has not been fixed./mysql/db table.

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

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

10. Start the mysql service.

/Usr/local/mysql/bin/mysqld_safe &

11. Check whether 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 running.

12. log on to mysql.

[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,201 0, 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 on.

13. Open the webpage and you can access it normally. This indicates that the MySQL database data table has been repaired successfully.

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.