How make mysql start automatically ? (linux-cli only)

How can i make mysql start every time the system boot ? I need that in a dedicated server(ubuntu distro) in which i have my blog, but every time the server goes down, on booting mysql is stopped.
Btw i can use only command line.


Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

update-rc.d allows setting init script links on Ubuntu and Debian Linux systems to control what services are run by init when entering various runlevels. It should be able to add mysql to the list of services to run at boot:

sudo update-rc.d mysql defaults

If you later want to disable running mysql on bootup:

sudo update-rc.d mysql remove

Method 2

You can do it by using sysv-rc-conf, on debian based you can install it with sudo apt-get install sysv-rc-conf
then you can choose what start at boot with a simple X on the name of the deamon, all via command line

enter image description here

Method 3

Run the following command to see your mysql current status:

/sbin/chkconfig mysqld --list

it will return a line such as below:

 mysqld             0:off   1:off   2:off   3:off   4:off   5:off   6:off

to make mysql start every time the system boots, type the following:

 sudo /sbin/chkconfig mysqld on

Result now from ‘–list’ is:

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off

Method 4

No answer helped. Finally chkconfig and update-rc.d did not work with MySQL on my machine.

Solution, I had a file /etc/init/mysql.override which contained


i just deleted that file

$ sudo rm /etc/init/mysql.override

Method 5

did the job in my case (HostEurope VPS with Ubuntu 12.04)

Method 6

I had the same problem, so I checked how I disabled it in the first place:

Check your /etc/init/mysql.conf to make sure you don’t have start on commented out (like I did).

# MySQL Service

description     "MySQL Server"

author          "Mario Limonciello <<a href="" class="__cf_email__" data-cfemail="cdbeb8bda8bfa0fc8db8afb8a3b9b8e3aea2a0">[email protected]</a>>"

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

Rebooted the machine and it works.

$ sudo service mysql status
mysql start/running, process 972

Method 7

Use the chkconfig command as per the manpage

Method 8

Another place to look for clues as to what is and isn’t starting at boot time…

/etc/init.d/.depend.start (and its buddy at shutdown time, .depend.stop)

Here’s a little more info

I had 2 servers – after booting, 1 would have mysql running, the other not so much.

On the box where mysql was starting at boot time:

  • chkconfig wasn’t even installed
  • there were zero links from any scripts in /etc/rc?.d/* back to /etc/init.d/mysql
  • BUT… /etc/init.d/.depend.start contained:
    TARGETS = halt apache2 umountfs sendsigs networking umountroot reboot killprocs unattended-upgrades urandom mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo postfix single grub-common ondemand rc.local
    INTERACTIVE = apache2
    postfix: mysql
    single: killprocs dns-clean pppd-dns
    grub-common: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
    ondemand: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
    rc.local: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo

When I simply copied this file over to the problem server, and rebooted, mysql was up & running.

Method 9

With Debian 9, I installed MySQL today and typed “reboot” and mysqld restarted automatically. Also rebooted from my VPS dashboard, mysqld restarted automatically. In short, if you have Debian 9, there’s nothing extra to do, it just works.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x