dポイントプレゼントキャンペーン実施中!

mysqlのdatadirを以下の手順で変更するのですが、mysqlが起動しません。
datadirの変更方法を教えてください。

--
centosにyumコマンドでmysqlをインストールしました。
datadirを変更するため、/etc/my.cnfの[mysqld]セクションに以下の行を追加しました。

[mysqld]
#datadir=/var/lib/mysql
datadir=/opt/mysql

/opt/mysqlには、mysqlユーザ、グループに権限を与えています。
mkdir -p /opt/mysql
chown -R mysql:mysql /opt/mysql
chmod -R 775 /opt/mysql

変更後、起動するのですが、mysqlが起動しません。
/var/log/mysqld.logには、次のように出力されています。

110121 14:15:18 mysqld started
110121 14:15:18 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
110121 14:15:18 [Warning] option 'max_join_size': unsigned value 18446744073709551615 adjusted to 4294967295
110121 14:15:18 [Warning] Can't create test file /opt/mysql/localhost.lower-test
110121 14:15:18 [Warning] Can't create test file /opt/mysql/localhost.lower-test
110121 14:15:18 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: 'create'.
InnoDB: Cannot continue operation.
110121 14:15:18 mysqld ended

よろしくお願いします。

A 回答 (2件)

参考 URL によると SELinux が有効なとき、


mysql の datadir を変更すると同様なエラーに
なるようです。

SELinux を無効にするか、参考 URL にあるように
system-config-securitylevel を使い、
mysqld daemon に対する SELinux の保護を無効に
してみてはいかがでしょうか。

参考URL:http://oksoft.blogspot.com/2009/12/issues-with-s …
    • good
    • 0
この回答へのお礼

ありがとうございます。
ご指摘の方法で解決しました。

お礼日時:2011/01/23 17:22

> Can't create test file /opt/mysql/localhost.lower-test


となっているので、/opt/mysql に書けないのではないでしょうか。

mysql に /opt のアクセス権がないのかもしれません。

# su -s /bin/bash -c "touch /opt/mysql/foo" mysql
して、/opt/mysql にファイルが作成できるでしょうか。

この回答への補足

ありがとうございます。

ご指示のコマンドを実行しましたが、ファイルは作成できます。

[root@localhost lib]# cd /opt/mysql/
[root@localhost mysql]# ll
合計 20
-rw-r--r-- 1 mysql mysql 0 1月 21 14:18 foo

補足日時:2011/01/23 14:29
    • good
    • 0

お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!