2

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!

asked Dec 7, 2011 at 8:56
1
  • There seems to be some change in the way datadir is defined in 5.0 and 5.5 versions. Simply changing it in my.cnf does not help. MySQL will still look for data in /var/lib/mysql/ I usually uninstall and reinstall mysql to "fix" this! Commented Dec 15, 2011 at 13:56

3 Answers 3

1

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.

answered Dec 8, 2011 at 16:52
1

Based on the observation by @Gaius (+1), you have two options

OPTION 1

Create a symlink /var/lib/mysql to point to /data/mysql

ln -s /data/mysql /var/lib/mysql

OPTION 2

Change the following in my.cnf

[mysqld]
datadir = /data/mysql

CAVEAT

Make sure all of /data/mysql is owned by mysql

chown -R mysql:mysql /data/mysql

Give it a Try !!!

answered Dec 8, 2011 at 17:11
1
  • 1
    Also if you have moved where my.cnf lives, then you would need to set the environment variable MYSQL_HOME to that directory. Commented Dec 9, 2011 at 15:37
0

The following commands should fix your problem if you have the same problem I had:

cp /etc/init.d/mysql /etc/init.d/mysqlnew
rm /etc/init.d/mysql
mv /etc/init.d/mysqlnew /etc/init.d/mysql

I just ran in to the same issue. In my case it turned out to be something wrong with the startup script file that was in the init.d path.

The /etc/init.d/mysql file was the binary equivalent of /usr/share/mysql/mysql.server The permissions, owner, and group, were the exact same

I moved the bad file, and renamed it mysqlwtf, and replaced the init.d script with a good copy.

See this snippet from my shell session to see the proof that the problem was the file itself(but not the content):

[root@myserver ~]# ./mysqlwtf start
Starting MySQL.. ERROR! The server quit without updating PID file (/mysql/myserver.mydomain.local.pid).
[root@myserver ~]# cp mysqlwtf mysqlwtf2
[root@myserver ~]# ./mysqlwtf2 start
Starting MySQL... SUCCESS!
answered Mar 15, 2013 at 15:27

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.