Thesql cannot start because of init.d folder

MySQL

After I setup mysql 5.5, I changed the data dir to another folder and modify the related config in my.cnf. This is quite simple, but mysql cannot start anymore even if reinstall or not change data dir.

The error log has no useful information, so I cannot find any reason.

111207 16:28:02 mysqld_safe Starting mysqld daemon with databases from
/var/lib/mysql 111207 16:28:02 mysqld_safe mysqld from pid file
/var/lib/mysql/localhost.localdomain.pid ended

But if I use the command as the start script, mysql starts normally.

/usr/bin/mysqld_safe –datadir=/data/mysql/
–pid-file=/data/mysql/localhost.localdomain.pid > /dev/null 2>&1

Much more strange, I use /usr/share/mysql/mysql.server start instead of /etc/init.d/mysql start, mysql also can start without error, while these two files are the same. So in the end I have to use cp -l /usr/share/mysql/mysql.server /etc/init.d/mysql to fix the problem.

I really want to know why and if there is a better solution!

Best Answer

In the first one it is looking for a DB in /var/lib/mysql (the default) and in the second, it is looking in /data/mysql, where you have moved to.