title: Can not start mysql if the datadir is set to soft link
body: <p>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:</p>
  
  <pre><code>sudo /etc/init.d/mysql start
  </code></pre>
  
  <p>Starting MySQL...SUCCESS.
  And the mysql would work fine.</p>
  
  <p>But I need to change the datadir to another partition due to the device space.
  It would show:</p>
  
  <pre><code>[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).
  </code></pre>
  
  <p>I just try every information about it, <strong>here is the detail about the settings</strong>:</p>
  
  <p>=> 1. <strong>if the folder is in /var/lib/mysql, everything is fine</strong>:</p>
  
  <pre><code>drwxrwxrwx 6 mysql mysql 4096 Mar 27 06:03 mysql
  </code></pre>
  
  <p>=> 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)</p>
  
  <p><strong>Permission for /test partition: (in /test)</strong></p>
  
  <pre><code>[admin@shwzu /]$ ls -l
  
  drwxrwxrwx   7 root root  4096 Mar 27 06:27 test
  </code></pre>
  
  <p><strong>Permission for /test/mysql folder:</strong></p>
  
  <pre><code>drwxr-xr-x 6 mysql mysql  4096 Mar 27 06:24 mysql
  </code></pre>
  
  <p><strong>Permission inside the /test/mysql folder:</strong></p>
  
  <pre><code>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
  </code></pre>
  
  <p><strong>Permission for soft link: (in /var/lib/mysql)</strong></p>
  
  <pre><code>  lrwxrwxrwx 1 mysql mysql   12 Mar 26 10:34 mysql -&gt; /test/mysql
  </code></pre>
  
  <p>Do init command: <code>sudo mysql_install_db</code>. And it work fine.</p>
  
  <ol>
  <li><strong>Error message</strong>:</li>
  </ol>
  
  <p>[admin@shwzu lib]$ sudo /etc/init.d/mysql start
  Starting MySQL. ERROR! The server quit without updating PID file</p>
  
  <p>(/var/lib/mysql/datadir/shwzu.pid).</p>
  
  <p>And the shwzu.err file which is in /test/mysql/datadir would show:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>==> <strong>So strange! There is no other message here, only two lines!!!!!!</strong></p>
  
  <ol>
  <li><p><strong>Double check</strong>:</p>
  
  <p>1) There's no mysql process.</p>
  
  <p>2) Threre's no zombie process.</p>
  
  <p>3) The owner and user are set to "mysql" for mysql folder and the files which in it.</p>
  
  <p>4) Clean all the content in datadir. => Failed with the same message.</p></li>
  <li><p><strong>Try and Error</strong>:</p>
  
  <p>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):</p>
  
  <p>lrwxrwxrwx 1 mysql mysql   12 Mar 26 10:38 mysql -> mysql_</p>
  
  <pre><code>[Result]: Failed with the same message.
  </code></pre>
  
  <p>2) Modify the /etc/my.cnf to the target folder "/test/mysql" instead of using soft link:</p>
  
  <pre><code>[Result]: Failed with the same message.
  </code></pre>
  
  <p>3) Copy the success folder "/var/lib/mysql" to "/test/mysql" and create a soft link:</p>
  
  <pre><code>[Result]: Failed with the same message.
  </code></pre></li>
  </ol>
  
  <p>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?</p>
  
  <p>Many many thanks!</p>