赫謙小便籤

MySQL啟動、執行出現errno 13的問題

剛剛朋友的MySQL Server忽然掛掉,沒辦法正常匯入 … 查了log後看到以下訊息:

1
2
3
4
5
6
7
8
9
10
120505 12:08:27 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
120505 12:08:27  InnoDB: Initializing buffer pool, size = 8.0M
120505 12:08:27  InnoDB: Completed initialization of buffer pool
120505 12:08:27  InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to
InnoDB: the directory.
InnoDB: File name ./ibdata1
InnoDB: File operation call: 'open'.
InnoDB: Cannot continue operation.
120505 12:08:27 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

科科,炸了=_=

上網找了一下看到這篇Mysql won’t start - ibdata1 corrupt? - operating system error number 13 - permissions issue

讚,頭彩 … 馬上讀一下發現到這個指令: perror 13,輸入之後告訴我 Error code 13代表的是Permission denied,就覺得很奇怪 …

跳到 /var/lib/mysql (MySQL根目錄,資料檔都放在這底下) 後,下 ls -l發現某些檔案的權限亂掉 … 所以用 chown -R mysql *來修復權限,至少把owner改為mysql就可以了。

結束之後重新啟動,果然正常 … 開開心心匯入資料去

Comments