Start MySQL on Startup

61,102

Solution 1

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

Solution 2

Enter this command:

sudo update-rc.d mysql defaults

Solution 3

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
Share:
61,102

Related videos on Youtube

Kohjah Breese
Author by

Kohjah Breese

Nikola

Updated on September 18, 2022

Comments

  • Kohjah Breese
    Kohjah Breese over 1 year

    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?

  • Kohjah Breese
    Kohjah Breese over 10 years
    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
    Kohjah Breese over 10 years
    This appears to give advice: ubuntuforums.org/showthread.php?t=1475798 Will report on results after reboot.
  • automatix
    automatix almost 8 years
    @KohjahBreese The solution works for me. Have you already rebooted, in order to accept the answer? ;)
  • Vineet
    Vineet over 7 years
    Worked like a charm :)