一次不法關機招致mysql數據表破壞的實例處理。本站提示廣大學習愛好者:(一次不法關機招致mysql數據表破壞的實例處理)文章只能為提供參考,不一定能成為您想要的結果。以下是一次不法關機招致mysql數據表破壞的實例處理正文
排查修單數據表的經由:
1、拜訪網頁,提醒毛病,銜接不到數據庫。
2、啟動mysql辦事,卸載和封閉rpm裝置的mysql辦事
(昨天裝置postfix似乎yum裝置了mysql),用netstat -anp |grep mysqld 敕令檢查mysql辦事沒有起來,用mysql -uroot -p也銜接不到辦事器。
3、檢查毛病提醒:
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.
發明提醒數據庫表破壞。(./mysql/host)
4、修單數據庫表:
cd /var/lib/mysql/mysql
myisamchk -of host.MYI
- recovering (with keycache) MyISAM-table 'host.MYI'
Data records: 0
表host.MYI修復勝利。
5、再次啟動辦事,檢查辦事能否啟動,登錄mysql,照樣不可。所以再次檢查毛病日記。
/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、又發明./mysql/user表破壞。
[root@localhost mysql]# myisamchk -of user.MYI
- recovering (with keycache) MyISAM-table 'user.MYI'
Data records: 6
7、表修復勝利,然則照樣啟動不了辦事,持續看毛病日記。
/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、最初一個毛病,是./mysql/db表還沒有修復好持續修復./mysql/db表。
9、履行上面的敕令修復./mysql/db表:
[root@localhost mysql]# myisamchk -of db.MYI
- recovering (with keycache) MyISAM-table 'db.MYI'
Data records: 0
Data records: 2
10、最初啟動mysql辦事。
/usr/local/mysql/bin/mysqld_safe &
11、檢查辦事能否在運轉。
[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
這時候發明辦事已運轉。
12、登錄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, 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>
可以登錄。
13、翻開網頁,曾經可以正常拜訪了,解釋MySQL數據庫的數據表修復勝利。