Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

MySQL 啟動報錯:'./mysql-bin.index' not found (Errcode: 13) 權限修復方案

編輯:Linux 教學

MySQL 啟動失敗,錯誤日誌顯示:

150326 10:44:49 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
/usr/local/mysql/bin/mysqld: File './mysql-bin.index' not found (Errcode: 13)
150326 10:44:50 [ERROR] Aborting

原因分析

  • Errcode: 13 代表 Permission denied(權限不足)。
  • 檔案 mysql-bin.index 實際存在於資料目錄,但 MySQL 進程(通常以 mysql 用戶運行)無法讀寫該目錄下的檔案。
  • 常見於手動遷移資料目錄、複製檔案、或誤以 root 身分操作導致擁有者/群組變更為 root:root、權限為 700。

快速修復

# 遞歸將資料目錄擁有者改為 mysql 用戶與群組
chown -R mysql:mysql /usr/local/mysql/data

# 若二進制檔與配置也在 /usr/local/mysql 下,建議一併修正
chown -R mysql:mysql /usr/local/mysql

# 確認目錄權限至少為 750,檔案 640
chmod 750 /usr/local/mysql/data
find /usr/local/mysql/data -type f -exec chmod 640 {} \;

驗證啟動

systemctl start mysqld
# 或
/etc/init.d/mysqld start

應輸出 Starting MySQL: [ OK ]。

預防建議

  • 遷移資料目錄時,使用 rsync -a 保留屬性,或 cp -a。
  • 操作 MySQL 資料目錄前,先 systemctl stop mysqld。
  • 定期檢查 ls -l /usr/local/mysql/data/ 確認擁有者為 mysql:mysql。
  • 若使用 AppArmor/SELinux,確認策略允許 mysqld 讀寫資料目錄。

權限問題是 MySQL 遷移與升級中最常見的陷阱,養成「以服務用戶身分操作服務檔案」的習慣可避免 90% 此類故障。

Copyright © Windows教程網 All Rights Reserved