我试图更改mysql的data_dir。 所以我做了
sudo /etc/init.d/mysql stop
将/etc/mysql/my.cnf中的数据条目更改为新位置
sudo /etc/init.d/mysql start
失败了。日志说
151201 15:43:31 [Note] /usr/libexec/mysqld: Shutdown complete
151201 15:43:31 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
151201 16:06:15 mysqld_safe Starting mysqld daemon with databases from /data/data_raid5_0/mysql
151201 16:06:15 [Warning] Can't create test file /data/data_raid5_0/mysql/PEC630.lower-test
151201 16:06:15 [Warning] Can't create test file /data/data_raid5_0/mysql/PEC630.lower-test
/usr/libexec/mysqld: Can't change dir to '/data/data_raid5_0/mysql/' (Errcode: 13)
151201 16:06:15 [ERROR] Aborting
151201 16:06:15 [Note] /usr/libexec/mysqld: Shutdown complete
151201 16:06:15 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
我首先认为这是写权限问题,但在修复之后,我仍然在日志中遇到同样的错误。
有人能给我一些建议。谢谢!
答案 0 :(得分:0)
错误可能是因为您没有将正确的SELinux上下文恢复到MySQL新数据库。试试这个命令:
chcon -R --reference=/var/lib/mysql/ /data/data_raid5_0/mysql/
P.S。:MySQL配置文件是/etc/my.cnf
,而不是/etc/mysql/my.cnf
,但我认为这只是一个错字。