Mysql修改datadir导致无法启动问题解决方法
程序员文章站
2024-04-03 12:36:40
centos6.2,停止mysqld然后修改/etc/my.cnf datadir的位置,启动mysqld提示failed,查看日志
复制代码 代码如下:
120609...
centos6.2,停止mysqld然后修改/etc/my.cnf datadir的位置,启动mysqld提示failed,查看日志
复制代码 代码如下:
120609 11:31:31 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
120609 11:35:12 mysqld_safe starting mysqld daemon with databases from /mnt/hgfs/mysql_data
120609 11:35:13 [warning] can't create test file /mnt/hgfs/mysql_data/data.lower-test
120609 11:35:13 [warning] can't create test file /mnt/hgfs/mysql_data/data.lower-test
/usr/libexec/mysqld: can't change dir to '/mnt/hgfs/mysql_data/' (errcode: 13)
120609 11:35:13 [error] aborting
120609 11:35:13 [note] /usr/libexec/mysqld: shutdown complete
120609 11:35:13 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
新的datadir路径确实没问题,而且目录和目录下所有文件都是777权限,上层目录也有rx权限,只不过datadir和下属文件owner都是root(因为我用虚拟机挂载的windows的文件系统)。后来想到应该是selinux搞的鬼,设置为permissive模式之后正常启动mysqld。
复制代码 代码如下:
[root@data selinux]# getenforce
enforcing
[root@data selinux]# setenforce 0
[root@data selinux]# getenforce
permissive
setenforce 1 设置selinux 成为enforcing模式
setenforce 0 设置selinux 成为permissive模式
彻底关闭,vi /etc/selinux/config 修改 selinux=disabled
复制代码 代码如下:
# this file controls the state of selinux on the system.
# selinux= can take one of these three values:
# enforcing - selinux security policy is enforced.
# permissive - selinux prints warnings instead of enforcing.
# disabled - no selinux policy is loaded.
selinux=disabled
# selinuxtype= can take one of these two values:
# targeted - targeted processes are protected,
# mls - multi level security protection.
selinuxtype=targeted