1

Currently I met a mysql start issue and couldn't figure what happen here. if the datadir set in /var/lib/mysql, and start mysql:

sudo /etc/init.d/mysql start

Starting MySQL...SUCCESS. And the mysql would work fine.

But I need to change the datadir to another partition due to the device space. It would show:

[admin@shwzu lib]$ sudo /etc/init.d/mysql start
Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/datadir/shwzu.pid).

I just try every information about it, here is the detail about the settings:

=> 1. if the folder is in /var/lib/mysql, everything is fine:

drwxrwxrwx 6 mysql mysql 4096 Mar 27 06:03 mysql

=> 2. Change the target folder to another partition which name is "test". And create "mysql" folder. Also, I change the owner ans user to mysql. Then create a soft link. (sudo ln -s /test/mysql /var/lib/mysql)

Permission for /test partition: (in /test)

[admin@shwzu /]$ ls -l

drwxrwxrwx   7 root root  4096 Mar 27 06:27 test

Permission for /test/mysql folder:

drwxr-xr-x 6 mysql mysql  4096 Mar 27 06:24 mysql

Permission inside the /test/mysql folder:

drwxr-xr-x 5 mysql mysql 4096 Mar 27 06:24 datadir
drwxr-xr-x 2 mysql mysql 4096 Mar 27 06:24 ibdatadir
drwxr-xr-x 2 mysql mysql 4096 Mar 27 06:24 log
-rwxr-xr-x 1 mysql mysql  158 Mar 27 06:24 RPM_UPGRADE_MARKER
-rw-r----- 1 mysql mysql 2562 Mar 27 06:24 slow_queries.log
drwxr-xr-x 2 mysql mysql 4096 Mar 27 06:24 tmp
-rw-r----- 1 mysql mysql 2031 Mar 27 06:24 shwzu.err

Permission for soft link: (in /var/lib/mysql)

  lrwxrwxrwx 1 mysql mysql   12 Mar 26 10:34 mysql -> /test/mysql

Do init command: sudo mysql_install_db. And it work fine.

  1. Error message:

[admin@shwzu lib]$ sudo /etc/init.d/mysql start Starting MySQL. ERROR! The server quit without updating PID file

(/var/lib/mysql/datadir/shwzu.pid).

And the shwzu.err file which is in /test/mysql/datadir would show:

140327 09:56:24 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql/datadir
140327 09:56:24 mysqld_safe mysqld from pid file /var/lib/mysql/datadir/shwzu.pid ended

==> So strange! There is no other message here, only two lines!!!!!!

  1. Double check:

    1) There's no mysql process.

    2) Threre's no zombie process.

    3) The owner and user are set to "mysql" for mysql folder and the files which in it.

    4) Clean all the content in datadir. => Failed with the same message.

  2. Try and Error:

    1) Change the name "/var/lib/mysql" folder to "/var/lib/mysql_", and create a soft link(use soft link in the path which is same with the success folder):

    lrwxrwxrwx 1 mysql mysql 12 Mar 26 10:38 mysql -> mysql_

    [Result]: Failed with the same message.
    

    2) Modify the /etc/my.cnf to the target folder "/test/mysql" instead of using soft link:

    [Result]: Failed with the same message.
    

    3) Copy the success folder "/var/lib/mysql" to "/test/mysql" and create a soft link:

    [Result]: Failed with the same message.
    

I really have no idea about the issue, it's confuse me and I didn't find any workaround solution. Is someone who can help me for it?

Many many thanks!

4
  • What are the permissions and ownerships on the /test folder itself? And on /test/mysql (not the files in it)?
    – dkasipovic
    Mar 27, 2014 at 10:31
  • Thanks for reponse. Here is the permission: [av_admin@shwzu /]$ ls -l drwxrwxrwx 7 root root 4096 Mar 27 06:27 test (I filter the other partition which not for mysql) [av_admin@shwzu test]$ ls -l drwxr-xr-x 6 mysql mysql 4096 Mar 27 06:24 mysql drwxrwxrwx 5 root root 4096 Mar 25 10:44 mysql-cluster Thanks a lot. Mar 27, 2014 at 10:42
  • Can you add it to your question for more clarity, it is hard to read it this way. You need to make sure that datadir is owned by mysql (I suppose the /test/mysql directory itself and all subdirectories.
    – dkasipovic
    Mar 27, 2014 at 10:43
  • Dear Kasipovic, Just modify my question. Many thanks for your reminding. Mar 27, 2014 at 10:50

3 Answers 3

2

Please check your server configuration file. I found "symbolic-links = 0" in my /etc/my.cnf and added a "#" in front of that line:

[mysqld]
# Disabling symbolic-links is recommended to prevent assorted security risks; to do so, uncomment this line:
#symbolic-links = 0
1
  • Did not help. There was not even that setting in my my.cnf file on Ubuntu. I also tried adding the setting and making it 1, but still the Job failed to start.
    – Rehmat
    Aug 23, 2016 at 11:49
2

If someone else finds this issue, instead of creating symbolic link of the MySQL data dir, please change the datadir setting itself in my.cnf

Make it like:

datadir = /some/other/drive/mysql

Actually, just changing datadir in my.cnf did not work. I had to change data dir in this file also: /etc/apparmor.d/usr.sbin.mysqld

And then:

/etc/init.d/apparmor reload

As taken from: How to change MySQL data directory?

1
  • I had this error happening after a system (mint?, mysql?) update. Changing appamror config for mysql as indicated in this answer was the solution.
    – koriander
    Dec 29, 2019 at 16:55
0

apparmor ist the culprit!

in case you've moved mysql to /data/mysql

edit /etc/apparmor.d/tunables/alias there is even a mysql samle line, just uncomment it.

# Or if mysql databases are stored in /home:  
alias /var/lib/mysql/ -> /data/mysql/,

restart apparmor

service apparmor restart

restart mysqld

service mysql start

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.