Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've installed mysql on Ubuntu, and the documentation on starting it up says:

Invoke mysql.server. This script is used primarily at system startup and shutdown on systems that use System V-style run directories (that is, /etc/init.d and run-level specific directories), where it usually is installed under the name mysql. The mysql.server script starts the server by invoking mysqld_safe.

However, the mysql file in /etc/init.d is simply linked to /lib/init/upstart-job, and the mysql.conf file in /etc/init is this:

# MySQL Service

description     "MySQL Server"
author          "Mario Limonciello <>"

start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]

respawn limit 2 5

env HOME=/etc/mysql
umask 007

# The default of 5 seconds is too low for mysql which needs to flush buffers
kill timeout 300

pre-start script
    #Sanity checks
    [ -r $HOME/my.cnf ]
    [ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld
    /lib/init/apparmor-profile-load usr.sbin.mysqld
    LC_ALL=C BLOCKSIZE= df --portability /var/lib/mysql/. | tail -n 1 | awk '{ exit ($4<4096) }'
end script

exec /usr/sbin/mysqld

post-start script
   for i in `seq 1 30` ; do
        /usr/bin/mysqladmin --defaults-file="${HOME}"/debian.cnf ping && {
            exec "${HOME}"/debian-start
            # should not reach this line
            exit 2
        if echo $statusnow | grep -q 'stop/' ; then
            exit 0
        elif echo $statusnow | grep -q 'respawn/' ; then
            exit 1
        sleep 1
    exit 1
end script

I have two questions:

  • Is the documentation wrong?
  • How can I configure mysql to start under mysqld_safe?
share|improve this question
What version of MySQL are you using? – ponsfonze Jan 16 '13 at 16:38
(mysqld_safe was remove in MySQL 5.1) – ponsfonze Jan 16 '13 at 16:43
You are wrong. safe_mysqld was removed. mysqld_safe is still the recommended way to run mysql according to the 5.6 documentation. – Chris B. Jan 16 '13 at 16:50
I suspect that it has to do with the conversion to an upstart job. Perhaps the packagers though upstart was better and making sure that mysqld was running then mysqld_safe. – Zoredache Jan 16 '13 at 18:15
Maybe they thought Upstart was better at ensuring mysql was running, but I've only discovered this because our mysqld process is crashing, and not restarting. So maybe they're wrong? – Chris B. Jan 16 '13 at 19:25
up vote 2 down vote accepted

Currently, mysqld_safe is part of MySQL 5.5. I cannot speak for Ubuntu-specific things.

First, find out if mysqld_safe is present and accessible. Run this:

which mysqld_safe

If it returns with the absolute path to the mysqld_safe program such as

[root@**** mysql]# which mysqld_safe

then you could replace

exec /usr/sbin/mysqld


exec /usr/sbin/mysqld_safe

Then, service mysql start.

Please do this on a Dev/Staging server first. For emphasis, I cannot speak for Ubuntu.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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