1

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 <[email protected]>"

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

respawn
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
        }
        statusnow=`status`
        if echo $statusnow | grep -q 'stop/' ; then
            exit 0
        elif echo $statusnow | grep -q 'respawn/' ; then
            exit 1
        fi
        sleep 1
    done
    exit 1
end script

I have two questions:

  • Is the documentation wrong?
  • How can I configure mysql to start under mysqld_safe?
5
  • What version of MySQL are you using?
    – ponsfonze
    Jan 16, 2013 at 16:38
  • (mysqld_safe was remove in MySQL 5.1) dev.mysql.com/doc/refman/5.0/en/mysqld-safe.html
    – ponsfonze
    Jan 16, 2013 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, 2013 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, 2013 at 18:15
  • 1
    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, 2013 at 19:25

1 Answer 1

2

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
/usr/bin/mysqld_safe

then you could replace

exec /usr/sbin/mysqld

with

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .