MySQL錯誤修復:Table crashed repair

問題一 Table xx is marked as crashed and last (automatic?) repair failed

有開發找到我,說數據庫壞了,連不上數據庫,看了下 MySQL 的錯誤日誌,報錯以下:html

Error: Table './db_name/table_name' is marked as crashed and last (automatic?) repair failed

修復

一、先中止 MySQL:service mysqld stop
二、進入到 MySQL 數據庫的文件存放目錄,好比 cd /data/mysql_data/xx_db
而後執行以下命令:mysql

myisamchk --safe-recover -f -r *.MYI

執行完成後,爲了保險起見,咱們要將文件的權限改回 MySQL 的運行帳號(自行查看),好比 mysql:sql

chown -R mysql:mysql .

三、啓動 MySQL:service mysqld start
四、最後,執行再次自動修復優化命令便可解決:數據庫

mysqlcheck --auto-repair --optimize --all-databases -p密碼

問題二 /usr/local/mysql/bin/mysqld does not exist or is not executable.

]# /data/wapage/hhzk/mserver/mysql5713/bin/mysqld_safe  --defaults-file=/etc/my.cnf &
[1] 24527
]# 2020-11-23T10:36:45.803151Z mysqld_safe Logging to '/data/wapage/hhzk/mserver/mysql5713/data/qd01-tech2-rec-build001.ps.easou.com.err'.
2020-11-23T10:36:45.809116Z mysqld_safe The file /usr/local/mysql/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&
See http://dev.mysql.com/doc/mysql/en/mysqld-safe.html for more information

[1]+  Exit 1                  /data/wapage/hhzk/mserver/mysql5713/bin/mysqld_safe --defaults-file=/etc/my.cnf

說明:mysqld_safe啓動腳本默認的從/usr/local/mysql目錄中讀取另一個啓動腳本mysqld,由於個人安裝目錄爲/data/wapage/hhzk/mserver/mysql5713。因此找不到相關文件。能夠從兩個方面解決。
方法一:在/usr/local/mysql建立連接文件bash

mkdir -p /usr/local/mysql/bin
ln -s /data/wapage/hhzk/mserver/mysql5713/bin/mysqld /usr/local/mysql/bin/mysqld

方法二:將mysqld_safe中的全部/usr/local/mysql目錄改成本身實際的安裝目錄ide

sed -i 's#/usr/local/mysql#/data/wapage/hhzk/mserver/mysql5713#g'  /data/wapage/hhzk/mserver/mysql5713/bin/mysqld_safe
相關文章
相關標籤/搜索