日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

mysql 异常关机后 无法查数据_MySQL数据库非法关机造成数据表损坏怎么排查 | 学步园...

發布時間:2025/3/15 数据库 21 豆豆
生活随笔 收集整理的這篇文章主要介紹了 mysql 异常关机后 无法查数据_MySQL数据库非法关机造成数据表损坏怎么排查 | 学步园... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

該篇文章我們介紹由于非法硬件關機,造成了MySQL數據庫的數據表損壞,數據庫不能正常運行的一個實例。下面學步園小編來講解下MySQL數據庫非法關機造成數據表損壞怎么排查?

MySQL數據庫非法關機造成數據表損壞怎么排查

1、訪問網頁,提示錯誤,連接不到數據庫。

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

3、查看錯誤提示:

11072617:02:23[ERROR]Can'topenthemysql.plugintable.Pleaserunmysql_upgradetocreateit.11072617:02:23[ERROR]/usr/local/mysql/libexec/mysqld:Table'./mysql/host'ismarkedascrashedandlast(automatic)repairfailed11072617:02:23[ERROR]Fatalerror:Can'topenandlockprivilegetables:Table'./mysql/host'ismarkedascrashedandlast(automatic)repairfailed11072617:02:23mysqld_safemysqldfrompidfile/var/lib/mysql/localhost.localdomain.pidended11072617:24:31mysqld_safeStartingmysqlddaemonwithdatabasesfrom/var/lib/mysql11072617:24:31[Warning]'--skip-locking'isdeprecatedandwillberemovedinafuturerelease.Pleaseuse'--skip-external-locking'instead.

發現提示數據庫表損壞。(./mysql/host)

4、修復數據庫表:

cd/var/lib/mysql/mysqlmyisamchk-ofhost.MYI-recovering(withkeycache)MyISAM-table'host.MYI'Datarecords:0表host.MYI修復成功。

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

/usr/local/mysql/libexec/mysqld:Table'./mysql/plugin'ismarkedascrashedandlast(automatic)repairfailed/usr/local/mysql/libexec/mysqld:Table'plugin'ismarkedascrashedandlast(automatic)repairfailed11072617:24:31[ERROR]Can'topenthemysql.plugintable.Pleaserunmysql_upgradetocreateit.11072617:24:31[ERROR]/usr/local/mysql/libexec/mysqld:Table'./mysql/user'ismarkedascrashedandlast(automatic)repairfailed11072617:24:31[ERROR]Fatalerror:Can'topenandlockprivilegetables:Table'./mysql/user'ismarkedascrashedandlast(automatic)repairfailed11072617:24:31mysqld_safemysqldfrompidfile/var/lib/mysql/localhost.localdomain.pidended11072617:27:13mysqld_safeStartingmysqlddaemonwithdatabasesfrom/var/lib/mysql11072617:27:13[Warning]'--skip-locking'isdeprecatedandwillberemovedinafuturerelease.Pleaseuse'--skip-external-locking'instead.

6、又發現./mysql/user表損壞。

[chinastor.com-root@localhostmysql]#myisamchk-ofuser.MYI-recovering(withkeycache)MyISAM-table'user.MYI'Datarecords:6

MySQL數據庫非法關機造成數據表損壞怎么排查

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

/usr/local/mysql/libexec/mysqld:Table'./mysql/plugin'ismarkedascrashedandlast(automatic)repairfailed/usr/local/mysql/libexec/mysqld:Table'plugin'ismarkedascrashedandlast(automatic)repairfailed11072617:27:13[ERROR]Can'topenthemysql.plugintable.Pleaserunmysql_upgradetocreateit.11072617:27:13[ERROR]/usr/local/mysql/libexec/mysqld:Table'./mysql/db'ismarkedascrashedandlast(automatic)repairfailed11072617:27:13[ERROR]Fatalerror:Can'topenandlockprivilegetables:Table'./mysql/db'ismarkedascrashedandlast(automatic)repairfailed11072617:27:13mysqld_safemysqldfrompidfile/var/lib/mysql/localhost.localdomain.pidended

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

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

[chinastor.com-root@localhostmysql]#myisamchk-ofdb.MYI-recovering(withkeycache)MyISAM-table'db.MYI'Datarecords:0Datarecords:2

10、最后啟動mysql服務。

/usr/local/mysql/bin/mysqld_safe&

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

[chinastor.com-root@localhost~]#netstat-anp|grepmysqldtcp000.0.0.0:33060.0.0.0:*LISTEN4360/mysqldunix2[ACC]STREAMLISTENING141724360/mysqld/tmp/mysql.sock

這時發現服務已運行。

12、登錄mysql試試。

[chinastor.com-root@localhost~]#mysql-uroot-p123456WelcometotheMySQLmonitor.Commandsendwith;or\g.YourMySQLconnectionidis35Serverversion:5.1.55-logSourcedistributionCopyright(c)2000,2010,Oracleand/oritsaffiliates.Allrightsreserved.ThissoftwarecomeswithABSOLUTELYNOWARRANTY.Thisisfreesoftware,andyouarewelcometomodifyandredistributeitundertheGPLv2licenseType'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.mysql>

能登錄。

13、在打開網頁,已經能正常訪問。證明MySQL數據庫的數據表就修復成功了。

以上就是關于“MySQL數據庫非法關機造成數據表損壞怎么排查”的內容,希望對大家有用。更多資訊請關注學步園。學步園,您學習IT技術的優質平臺!

總結

以上是生活随笔為你收集整理的mysql 异常关机后 无法查数据_MySQL数据库非法关机造成数据表损坏怎么排查 | 学步园...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。