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数据库非法关机造成数据表损坏怎么排查 | 学步园...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: esd管 低cj要求_TVS管与ESD保
- 下一篇: zabbix监控mysql的哪些参数_C