2

I realize that there are many questions around here to answer that problem - but none seems to work for me so far.

I attempted:

sudo update-rc.d mysql defaults

This resulted in a locale error, which I fixed with How do I fix my locale issue? by altering /etc/environment

LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8

Now, by trying update-rc.d again, I get:

update-rc.d: warning: /etc/init.d/mysql missing LSB information
update-rc.d: see <http://wiki.debian.org/LSBInitScripts>
 System start/stop links for /etc/init.d/mysql already exist.

I found a suggestion on http://ubuntuforums.org/showthread.php?t=1313898 to use:

user@computer:/etc/init.d$ sudo update-rc.d -f mystartupscript remove
user@computer:/etc/init.d$ sudo update-rc.d mystartupscript defaults
user@computer:/etc/init.d$ sudo chmod +x ./mystartupscript

But do I risk to break my mysql implementation here? It's on a production server, so I can't just try it out and then suddenly be unable to start up mysql again.

In the end, the mysql server needs to run on startup. We had a few server restarts coming from the host, and everytime when that's the case, the database is not started and the hosted pages remain down until mysql is started manually.

Edit: /etc/init.d/mysql contents

#!/bin/sh -e
# upstart-job
#
# Symlink target for initscripts that have been converted to Upstart.

set -e

INITSCRIPT="$(basename "$0")"
JOB="${INITSCRIPT%.sh}"

if [ "$JOB" = "upstart-job" ]; then
    if [ -z "$1" ]; then
        echo "Usage: upstart-job JOB COMMAND" 1>&2
        exit 1
    fi

    JOB="$1"
    INITSCRIPT="$1"
    shift
else
    if [ -z "$1" ]; then
        echo "Usage: $0 COMMAND" 1>&2
        exit 1
    fi
fi

COMMAND="$1"
shift


if [ -z "$DPKG_MAINTSCRIPT_PACKAGE" ]; then
        ECHO=echo
else
        ECHO=:
fi

$ECHO "Rather than invoking init scripts through /etc/init.d, use the service(8)"
$ECHO "utility, e.g. service $INITSCRIPT $COMMAND"

# Only check if jobs are disabled if the currently _running_ version of
# Upstart (which may be older than the latest _installed_ version)
# supports such a query.
#
# This check is necessary to handle the scenario when upgrading from a
# release without the 'show-config' command (introduced in
# Upstart for Ubuntu version 0.9.7) since without this check, all
# installed packages with associated Upstart jobs would be considered
# disabled.
#
# Once Upstart can maintain state on re-exec, this change can be
# dropped (since the currently running version of Upstart will always
# match the latest installed version).

UPSTART_VERSION_RUNNING=$(initctl version|awk '{print $3}'|tr -d ')')

if dpkg --compare-versions "$UPSTART_VERSION_RUNNING" ge 0.9.7
then
    initctl show-config -e "$JOB"|grep -q '^  start on' || DISABLED=1
fi

case $COMMAND in
status)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted to an"
    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
    $COMMAND "$JOB"
    ;;
start|stop)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted to an"
    $ECHO "Upstart job, you may also use the $COMMAND(8) utility, e.g. $COMMAND $JOB"
    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
        RUNNING=1
    fi
    if [ -z "$RUNNING" ] && [ "$COMMAND" = "stop" ]; then
        exit 0
    elif [ -n "$RUNNING" ] && [ "$COMMAND" = "start" ]; then
        exit 0
    elif [ -n "$DISABLED" ] && [ "$COMMAND" = "start" ]; then
        exit 0
    fi
    $COMMAND "$JOB"
    ;;
restart)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted to an"
    $ECHO "Upstart job, you may also use the stop(8) and then start(8) utilities,"
    $ECHO "e.g. stop $JOB ; start $JOB. The restart(8) utility is also available."
    if status "$JOB" 2>/dev/null | grep -q ' start/'; then
        RUNNING=1
    fi
    if [ -n "$RUNNING" ] ; then
        stop "$JOB"
    fi
    # If the job is disabled and is not currently running, the job is
    # not restarted. However, if the job is disabled but has been forced into the
    # running state, we *do* stop and restart it since this is expected behaviour
    # for the admin who forced the start.
    if [ -n "$DISABLED" ] && [ -z "$RUNNING" ]; then
        exit 0
    fi
    start "$JOB"
    ;;
reload|force-reload)
    $ECHO
    $ECHO "Since the script you are attempting to invoke has been converted to an"
    $ECHO "Upstart job, you may also use the reload(8) utility, e.g. reload $JOB"
    reload "$JOB"
    ;;
*)
    $ECHO
    $ECHO "The script you are attempting to invoke has been converted to an Upstart" 1>&2
    $ECHO "job, but $COMMAND is not supported for Upstart jobs." 1>&2
    exit 1
esac
Katai
  • 677
  • update-rc.d -f mystartupscript remove only removes the symlinks that you add with the same command without the remove. No harm done. update-rc.d tells you that the symlinks you are trying to create already exist, maybe the locale error also was only a warning? – BubuIIC Aug 25 '15 at 14:48
  • Also the LSB warning can be safely ignored. It looks like mysql should start automatically in your config. If it does not we have to dig further. – BubuIIC Aug 25 '15 at 14:56
  • @BubullC it definitely does not start automatically, I already tested that with restarts. I'll try to look into /var/log/syslog to see if I can spot anything relevant. If you have some suggestions for further informations I should provide (+commands) let me know ;) – Katai Aug 25 '15 at 15:04
  • Can you post the content of /etc/init.d/mysql? – BubuIIC Aug 25 '15 at 15:16
  • @BubullC added them as requested - as far as I know, I didn't tinker with them at all. MySQL wise, I did little more than a basic apt-get install mysql-server, if I recall correctly. – Katai Aug 25 '15 at 15:22

2 Answers2

1

Ok, two more things you can try: Try running the commands

user@computer:/etc/init.d$ sudo update-rc.d -f mysql remove
user@computer:/etc/init.d$ sudo update-rc.d mysql defaults

and see what the output is. There should be a number of symlinks cretead in /etc/rcX.d.

And secondly see if there is an /etc/init/mysql.override file which sets starting mysql startup to manual for upstart, the more modern Ubuntu startup system.

BubuIIC
  • 121
  • Sorry for the delay, but I didn't have access to the server until today. Yes, /etc/init/mysql.override exists, and the entry is manual - should I remove that? – Katai Sep 02 '15 at 10:16
  • 1
    Yes, if you remove that file mysql should start automatically, that should solve your problem. – BubuIIC Sep 07 '15 at 20:47
0

But do I risk to break my mysql implementation here?

Unlikely. It will not get in your way for manual starting MySQL anyways so if it does fail it just stays the same for you: no automatic starting but starting manually will still be possible.

This though ...

System start/stop links for /etc/init.d/mysql already exist.

... has me believe that there was already a start/stop for automatic starting. That would also have me believe you have some sort of problem with the automatic starting and changing it might not solve that problem (if there is).

Can you make sure that there are no notices in the logs inside /var/log/syslog (probably syslog) pointing to problems with the automatic starting of mysql before you change it. Because if there are it will be better to fix that.

Rinzwind
  • 299,756
  • That's why I was asking - I noticed that "already exists" line as well, and just figured it's talking about service mysql start/stop - and that's something I wanted to avoid to break, the reason for me avoiding tinkering with that. I'll check the logs and let you know. – Katai Aug 25 '15 at 15:03
  • Looking through the syslog, I only found a lot of other spam, but nothing relating to mysql after a message simply stating restart. (by the way, does that imply that there was a manual restart? Or are automatic restarts also logged like that?) Other than restart, there was only a series of connection and cronjob messages, nothing else as far as I can tell. mysql.log and mysql.err are both empty by the way. – Katai Aug 25 '15 at 15:19