一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數據庫技術|

服務器之家 - 數據庫 - Mysql - 一次非法關機導致mysql數據表損壞的實例解決

一次非法關機導致mysql數據表損壞的實例解決

2019-12-16 15:12MYSQL教程網 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數據庫的數據表修復成功。

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: www红色一片在线观看版 | 精品一区二区三区高清免费不卡 | nxgx欧美| 国产成人精品一区二区不卡 | 四虎影院永久在线 | 日本高清免费不卡在线播放 | 亚洲天堂视频在线观看免费 | 视频在线欧美 | 五月丁开婷婷 | 久久精品国产清白在天天线 | 国产日韩欧美不卡www | 男gaygays免费网站多人 | 国产成人精品免费 | a级亚洲片精品久久久久久久 | 亚洲日本中文字幕天堂网 | 美女gif跪趴式抽搐动态图 | 543精品视频 | 99久久精品国产综合一区 | 我被黄总征服的全过程 | 精品视频中文字幕 | 99久热只有精品视频免费观看17 | 亚洲夜色夜色综合网站 | 精品区2区3区4区产品乱码9 | 美女被吸乳老师羞羞漫画 | 色狠狠色狠狠综合天天 | 国产欧美综合精品一区二区 | 国产肥老上视频 | 欧美一级免费看 | 农村脱精光一级 | 国产精品性视频免费播放 | 午夜网 | 国产综合欧美日韩视频一区 | 色综合久久中文字幕网 | 2019理论韩国理论中文 | 亚洲国产天堂久久精品网 | 亚洲 国产精品 日韩 | 99久久精品久久久久久清纯 | 亚洲天天综合 | 鸭子玩富婆流白浆视频 | 日韩精品特黄毛片免费看 | 亚洲成人伦理 |