32

I installed MySQL, and changed the configuration so the databases are stored on a separate hard drive. In the process MySQL has stopped starting up automatically. When I start the computer, I need to run the command:

sudo service mysql start

to get MySQL to run. How do you get MySQL to start on boot?

2

Excuse me for being a bit off-topic by hijacking the slightly different issue here to provide solution to similar case. Since I stumbled over this thread by trying to solve my somewhat related issue I beg for your pardon.

I was having issues with starting mysql in an lxc container running Ubuntu 16.04. I tried update-rc.d mysql defaults as well as systemctl enable mysql.service several times but mysql didn't come up on boot. There wasn't even a log entry regarding some error to fix.

The lxc container is getting its network configuration via host's lxc configuration file but still was configured to start DHCP client enabled by default. By disabling DHCP in lxc container I stumbled over solution by accident. This was the reason for mysql not starting as it was waiting for DHCP client to finish. And DHCP didn't finish due to missing any response from unavailable DHCP service.

So, just in case you stumble over the same question here and find yourself in a similar dilemma try this: Edit /etc/network/interfaces and comment-out lines reading

auto eth0
iface eth0 inet dhcp
47

Enter this command:

sudo update-rc.d mysql defaults
  • 2
    Thanks. It is giving me the message: update-rc.d: warning: /etc/init.d/mysql missing LSB information update-rc.d: see <wiki.debian.org/LSBInitScripts> System start/stop links for /etc/init.d/mysql already exist. Seems there is another problem. – Kohjah Breese Feb 4 '14 at 23:53
  • This appears to give advice: ubuntuforums.org/showthread.php?t=1475798 Will report on results after reboot. – Kohjah Breese Feb 5 '14 at 0:06
  • 1
    @KohjahBreese The solution works for me. Have you already rebooted, in order to accept the answer? ;) – automatix May 26 '16 at 12:40
  • Worked like a charm :) – Vineet Dec 29 '16 at 8:59
0

Ubuntu with upstart init

Up to 14.04 Ubuntu uses upstart for init so we have to check its config: If /etc/init/mysql.override exists and contains manual then automatic starting of mysql is disabled.

Remove .override and reload config:

rm /etc/init/mysql.override
initctl reload-configuration

Alternatively if SysV init is used

First cleanup old startup config, then write new default config to avoid error System start/stop links for /etc/init.d/mysql already exist.

Execute as root:

update-rc.d -f mysql remove
update-rc.d mysql defaults

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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