首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫

MySQL 啟動失敗與備份失敗常見故障排查實戰案例集

     編輯:MySQL 資料庫相關知識

案例一:服務器重啟後 MySQL 無法啟動

現象

service mysql start
MySQL server PID file could not be found!
Starting MySQL.............. ERROR! The server quit without updating PID file (/mydata/data/fisheye.pid).

錯誤日志關鍵信息

InnoDB: 5.5.33 started; log sequence number 1006647152
mysqld got signal 11  -- 可能是 Bug、庫損壞、配置錯誤或硬件故障

排查定位:磁盤空間耗盡

df -h
/dev/sda1  9.5G  9.5G  0  100% /   ← 根分區滿

解決方案

  1. 修改 /etc/my.cnf 中 datadir 指向有空間的分區(如 /mnt/backup)。
  2. 遷移數據:tar -czpf /mnt/backup/mysql_data.tar.gz /mydata/data → 解壓到新目錄 → chown -R mysql:mysql 新目錄。
  3. 注意:遷移必須保留權限,大數據先壓縮再傳輸防超時,目標機 MySQL 版本需一致。

啟動失敗六大通用排查清單

原因排查命令/現象解決動作
數據目錄分區滿df -h 顯示 100%遷移 datadir 或清理空間
PID 文件無寫權限ls -l /mydata/data/ 屬主非 mysqlchown -R mysql:mysql /mydata/data/
殘留進程未清理ps -ef | grep mysqld 有進程kill -9 PID 後重啟
二次安裝殘留索引文件/mydata/data/mysql-bin.index 存在刪除該文件
配置項 skip-federated 未註釋錯誤日志 unknown option '--skip-federated'my.cnf 中註釋掉該行
SELinux 阻攔CentOS 默認 Enforcing/etc/selinux/config 設 SELINUX=disabled 重啟機器

案例二:mysqldump 備份報錯「Table doesn't exist」但表明明在

現象

mysqldump fx > fx.sql
mysqldump: Got error: 1146: Table 'user_suggest_report' doesn't exist when using LOCK TABLES

加 --skip-lock-tables 仍報:Couldn't read status information for table vote_results / show create table user_suggest_report: doesn't exist。

深度排查

  1. 進庫 SHOW TABLES; 表存在。
  2. DROP TABLE user_suggest_report; 報語法錯誤(元數據不一致)。
  3. 進數據目錄 /var/lib/mysql/fx/ 發現 user_suggest_report.frm 孤兒文件(無對應 .ibd)。
  4. 移走孤兒文件:mv user_suggest_report.frm /data/
  5. 重啟 MySQL:service mysqld restart
  6. 再次備份成功。

根因

表文件與 InnoDB 數據字典不同步(如誤刪 .ibd、崩潰恢復不全),導致 frm 孤兒。MySQL 以 frm 為準判定表存在,InnoDB 層找不到數據文件報錯。

預防建議

  • 定期 CHECK TABLE / ANALYZE TABLE 發現異常。
  • 備份前執行 FLUSH TABLES WITH READ LOCK 確保一致性(僅限小庫)。
  • 大表備份優先用物理備份工具(xtrabackup、mysqldump --single-transaction)。
  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved