操作系统:CentOS6.2
Mysql版本:MySQL-server-5.5.27
mysql使用rpm方式安装,安装成功后,在启动之前,将默认数据目录下的文件都复制到了指定的目录:
cp -r /var/lib/mysql/* /app/var/lib/mysql/
目录/app/var/lib/mysql/的所有者为mysql;
将一份编辑好的my.cnf文件复制到了/etc/下,其中
datadir =/app/var/lib/mysql
这时使用service启动mysql:
- [root@localhost mysql]# service mysql start
- Starting MySQL. ERROR! The server quit without updating PID file (/app/var/lib/mysql/localhost.localdomain.pid).
仔细检查了mysql脚本调用过程,发现服务启动时,会调用/usr/bin/mysqld_safe,于是,手工启动:
- [root@localhost mysql]# /usr/bin/mysqld_safe --datadir=/app/var/lib/mysql --pid-file=/app/var/lib/mysql/localhost.localdomain.pid &
- [1] 15396
- [root@localhost mysql]# 121106 08:08:00 mysqld_safe Logging to '/app/var/lib/mysql/localhost.localdomain.err'.
- 121106 08:08:00 mysqld_safe Starting mysqld daemon with databases from /app/var/lib/mysql
- [root@localhost mysql]# ps -ef|grep mysql
- root 15396 9673 0 08:07 pts/1 00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/app/var/lib/mysql --pid-file=/app/var/lib/mysql/localhost.localdomain.pid
- mysql 15898 15396 1 08:07 pts/1 00:00:00 /usr/sbin/mysqld --basedir=/usr --datadir=/app/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --user=mysql --log-error=/app/var/lib/mysql/localhost.localdomain.err --pid-file=/app/var/lib/mysql/localhost.localdomain.pid --socket=/app/var/lib/mysql/mysql.sock --port=3306
- root 15918 9673 0 08:08 pts/1 00:00:00 grep mysql
- [root@localhost mysql]#
登录mysql也正常,竟然启动成功了,仔细检查了文件权限,没有问题啊,为什么service mysql start就是不行呢,网上传的很多方法都不行,最后才发现/etc/selinux/config文件中,SELINUX=enforcing,改为disabled,重启linux,service mysql start终于成功了!
selinux是linux下的一种安全机制,没有深入研究过,以后有时间再仔细看看!
阅读(4134) | 评论(0) | 转发(0) |