一次非法關(guān)機(jī)導(dǎo)致mysql數(shù)據(jù)表損壞的實例解決
排查修復(fù)數(shù)據(jù)表的經(jīng)過:
1、訪問網(wǎng)頁,提示錯誤,連接不到數(shù)據(jù)庫。
2、啟動mysql服務(wù),卸載和關(guān)閉rpm安裝的mysql服務(wù)
(昨天安裝postfix好像yum安裝了mysql),用netstat -anp |grep mysqld 命令查看mysql服務(wù)沒有起來,用mysql -uroot -p也連接不到服務(wù)器。
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.
發(fā)現(xiàn)提示數(shù)據(jù)庫表損壞。(./mysql/host)
4、修復(fù)數(shù)據(jù)庫表:
cd /var/lib/mysql/mysql
myisamchk -of host.MYI
- recovering (with keycache) MyISAM-table 'host.MYI'
Data records: 0
表host.MYI修復(fù)成功。
5、再次啟動服務(wù),查看服務(wù)是否啟動,登錄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、又發(fā)現(xiàn)./mysql/user表損壞。
[root@localhost mysql]# myisamchk -of user.MYI
- recovering (with keycache) MyISAM-table 'user.MYI'
Data records: 6
7、表修復(fù)成功,但是還是啟動不了服務(wù),繼續(xù)看錯誤日志。
/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表還沒有修復(fù)好繼續(xù)修復(fù)./mysql/db表。
9、執(zhí)行下面的命令修復(fù)./mysql/db表:
[root@localhost mysql]# myisamchk -of db.MYI
- recovering (with keycache) MyISAM-table 'db.MYI'
Data records: 0
Data records: 2
10、最后啟動mysql服務(wù)。
/usr/local/mysql/bin/mysqld_safe &
11、查看服務(wù)是否在運(yùn)行。
[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
這時發(fā)現(xiàn)服務(wù)已運(yùn)行。
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、打開網(wǎng)頁,已經(jīng)可以正常訪問了,說明MySQL數(shù)據(jù)庫的數(shù)據(jù)表修復(fù)成功。
- MySQL有壞快后drop表就crash了的解決方案
- MySQL表數(shù)據(jù)文件損壞導(dǎo)致數(shù)據(jù)庫無法啟動的原因與解決方案
- 解決MySQL數(shù)據(jù)庫意外崩潰導(dǎo)致表數(shù)據(jù)文件損壞無法啟動的問題
- Mysql存儲引擎MyISAM的常見問題(表損壞、無法訪問、磁盤空間不足)
- shell腳本自動修復(fù)mysql損壞的表
- MySQL數(shù)據(jù)庫INNODB表損壞修復(fù)處理過程分享
- MYSQL數(shù)據(jù)表損壞的原因分析和修復(fù)方法小結(jié)(推薦)
- MySQL數(shù)據(jù)表損壞的正確修復(fù)方案
- Mysql 壞表修復(fù)的幾種解決方案
相關(guān)文章
在SpringBoot中實現(xiàn)WebSocket會話管理的方案
在構(gòu)建實時通信應(yīng)用時,WebSocket 無疑是一個強(qiáng)大的工具,SpringBoot提供了對WebSocket的支持,本文旨在探討如何在 Spring Boot 應(yīng)用中實現(xiàn) WebSocket 會話管理,我們將通過一個模擬的場景一步步展開討論,需要的朋友可以參考下2023-11-11
MySQL數(shù)據(jù)庫引擎介紹、區(qū)別、創(chuàng)建和性能測試的深入分析
本篇文章是對MySQL數(shù)據(jù)庫引擎介紹、區(qū)別、創(chuàng)建和性能測試進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下2013-06-06
Mysql ERROR 1067: Invalid default v
這篇文章主要介紹了Mysql ERROR 1067: Invalid default value for字段問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-05-05

