MySQLサーバが起動できない場合の対処方法

いろいろ原因はあるようだけど、一つのパターンということで。


MySQL のデータベースの位置を標準から変更すると、SELinux の制限に引っかかって起動できなくなることがある。


MySQL のデータベースの位置は /etc/my.cnf に

datadir=/hoge/hage

で指定することが出来る。


SELinux が有効になっていると、/var/log/mysqld.log に以下のようなメッセージが記録される。

130127 22:32:12 mysqld_safe Starting mysqld daemon with databases from /hoge/hage/mysql
130127 22:32:12 [Warning] Can't create test file /usr/temp/mysql/hostname.lower-test
130127 22:32:12 [Warning] Can't create test file /usr/temp/mysql/hostname.lower-test
130127 22:32:12  InnoDB: Initializing buffer pool, size = 8.0M
130127 22:32:12  InnoDB: Completed initialization of buffer pool
130127 22:32:12  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.
130127 22:32:12 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended

SELinux を無効にするか、mysqld_t、mysqld_safe に適切な許可設定をすることで mysqld が起動するようになる。