自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

一個MySQL數(shù)據(jù)庫非法關(guān)機造成數(shù)據(jù)表損壞的實例

數(shù)據(jù)庫 MySQL
本文主要介紹了修復由于非法硬件關(guān)機造成MySQL數(shù)據(jù)庫數(shù)據(jù)表損壞的過程,希望能夠?qū)δ兴鶐椭?/div>

本文我們介紹由于非法硬件關(guān)機,造成了MySQL數(shù)據(jù)庫數(shù)據(jù)表損壞,數(shù)據(jù)庫不能正常運行的一個實例,接下來是作者排查錯誤的過程,讓我們來一起了解一下吧。

排查修復數(shù)據(jù)表的經(jīng)過如下:

 

1、訪問網(wǎng)頁,提示錯誤,連接不到數(shù)據(jù)庫。

2、啟動mysql服務,卸載和關(guān)閉rpm安裝的mysql服務(昨天安裝postfix好像yum安裝了mysql),用netstat -anp |grep mysqld 命令查看mysql服務沒有起來,用mysql -uroot -p也連接不到服務器。

3、查看錯誤提示:

 

  1. 110726 17:02:23 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.  
  2.  
  3. 110726 17:02:23 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/host' is marked as crashed and last (automatic?) repair failed  
  4.  
  5. 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  
  6.  
  7. 110726 17:02:23 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended  
  8.  
  9. 110726 17:24:31 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql  
  10.  
  11. 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、修復數(shù)據(jù)庫表:

 

  1. cd /var/lib/mysql/mysql  
  2.  
  3. myisamchk -of host.MYI  
  4.  
  5. - recovering (with keycache) MyISAM-table 'host.MYI'  
  6.  
  7. Data records: 0  
  8.  
  9. 表host.MYI修復成功。 

 

5、再次啟動服務,查看服務是否啟動,登錄mysql,還是不行。所以再次查看錯誤日志。

 

  1. /usr/local/mysql/libexec/mysqld: Table './mysql/plugin' is marked as crashed and last (automatic?) repair failed  
  2.  
  3. /usr/local/mysql/libexec/mysqld: Table 'plugin' is marked as crashed and last (automatic?) repair failed  
  4.  
  5. 110726 17:24:31 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.  
  6.  
  7. 110726 17:24:31 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/user' is marked as crashed and last (automatic?) repair failed  
  8.  
  9. 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  
  10.  
  11. 110726 17:24:31 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended  
  12.  
  13. 110726 17:27:13 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql  
  14.  
  15. 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表損壞。

 

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

 

7、表修復成功,但是還是啟動不了服務,繼續(xù)看錯誤日志。

 

  1. /usr/local/mysql/libexec/mysqld: Table './mysql/plugin' is marked as crashed and last (automatic?) repair failed  
  2.  
  3. /usr/local/mysql/libexec/mysqld: Table 'plugin' is marked as crashed and last (automatic?) repair failed  
  4.  
  5. 110726 17:27:13 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.  
  6.  
  7. 110726 17:27:13 [ERROR] /usr/local/mysql/libexec/mysqld: Table './mysql/db' is marked as crashed and last (automatic?) repair failed  
  8.  
  9. 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  
  10.  
  11. 110726 17:27:13 mysqld_safe mysqld from pid file /var/lib/mysql/localhost.localdomain.pid ended 

 

8、最后一個錯誤,是./mysql/db表還沒有修復好繼續(xù)修復./mysql/db表。

9、執(zhí)行下面的命令修復./mysql/db表:

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

 

10、最后啟動mysql服務。

 

  1. /usr/local/mysql/bin/mysqld_safe & 

 

11、查看服務是否在運行。

 

  1. [root@localhost ~]# netstat -anp | grep mysqld  
  2.  
  3. tcp        0      0   
  4.  
  5. 0.0.0.0:3306                  
  6.  
  7. 0.0.0.0:*                   LISTEN        
  8.  
  9. 4360/mysqld           
  10.  
  11. unix  2      [ ACC ]     STREAM     LISTENING     14172    
  12.  
  13. 4360/mysqld         /tmp/mysql.sock 

 

這時發(fā)現(xiàn)服務已運行。

12、登錄mysql試試。

 

  1. [root@localhost ~]# mysql -uroot -p123456  
  2.  
  3. Welcome to the MySQL monitor.  Commands end with ; or \g.  
  4.  
  5. Your MySQL connection id is 35  
  6.  
  7. Server version: 5.1.55-log Source distribution  
  8.  
  9. Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.  
  10.  
  11. This software comes with ABSOLUTELY NO WARRANTY. This is free software,  
  12.  
  13. and you are welcome to modify and redistribute it under the GPL v2 license  
  14.  
  15. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.  
  16.  
  17. mysql>  

 

能登錄。

13、在打開網(wǎng)頁,已經(jīng)能正常訪問。證明MySQL數(shù)據(jù)庫的數(shù)據(jù)表就修復成功了。

關(guān)于MySQL數(shù)據(jù)庫數(shù)據(jù)表損壞的問題就介紹到這里了,如果您有興趣了解更多關(guān)于MySQL數(shù)據(jù)庫的知識,可以看一下這里的文章:http://database.51cto.com/mysql/,相信一定會帶給您收獲的!

【編輯推薦】

  1. 用mysqldumpslow分析執(zhí)行較慢的SQL語句
  2. 關(guān)于MySQL事務的操作示例以及注意事項
  3. 使用MySQL Proxy告終讀寫離別的操作實例
  4. 開啟了log-bin的MySQL數(shù)據(jù)庫如何備份還原
  5. MySQL數(shù)據(jù)庫安裝過程中常見錯誤的解決方案
責任編輯:趙鵬 來源: 網(wǎng)易博客
相關(guān)推薦

2010-06-09 16:55:47

MySQL數(shù)據(jù)表

2010-05-12 18:35:25

MySQL數(shù)據(jù)表

2011-07-20 17:02:51

Oracle數(shù)據(jù)庫

2017-05-25 10:23:13

數(shù)據(jù)a表b表

2010-06-13 17:35:17

MySQL數(shù)據(jù)表

2011-07-20 13:40:00

SQLite數(shù)據(jù)庫查詢數(shù)據(jù)

2010-05-17 17:54:39

MySQL 數(shù)據(jù)庫

2011-07-20 12:55:17

SQLite數(shù)據(jù)庫插入數(shù)據(jù)

2010-05-20 14:25:25

2018-02-25 17:30:18

2011-07-20 13:18:01

SQLite數(shù)據(jù)庫修改和刪除數(shù)據(jù)

2022-12-28 08:17:36

數(shù)據(jù)庫數(shù)據(jù)導出

2011-07-20 14:57:47

SQLite數(shù)據(jù)庫ORDER BYGROUP BY

2011-08-18 18:18:05

MySQL數(shù)據(jù)庫優(yōu)化

2011-07-21 16:28:20

MySQL數(shù)據(jù)庫帶游標的存儲過程

2011-08-22 16:41:35

MySQL1067進程意外終止

2021-03-04 14:10:04

Mysql數(shù)據(jù)庫數(shù)據(jù)表

2011-08-02 12:46:46

Oracle數(shù)據(jù)表建立索引

2009-06-22 13:50:00

java連接mysql

2010-05-12 18:41:34

MySQL數(shù)據(jù)庫
點贊
收藏

51CTO技術(shù)棧公眾號