How to stop MySQL from running on boot

Wondering why MySQL server stubbornly kept on starting itself on boot although you turned it off on BUM (BootUp-Manager) or chkconfig?

Well, stop wondering now!

The file that controls MySQL to start on boot is located  in the /etc/init directory in a file aptly named mysql.conf. In order to stop the service from running again on boot, comment out a couple of lines as shown below.

# start on (net-device-up
#          and local-filesystems)

What happens is that the upstart init daemon being used by Ubuntu looks into the /etc/init directory and start or stop processes based on events.  That is what the lines above mean.  Commenting out those lines will make upstart ignore what it says. You may also want to put in another value (or event) that upstart recognizes to have the mysql server daemon start on a different event.  I will not cover that here as that is still kind of vague for me.

As always, open the file with administrator (root) privilege so you can effectively edit and save it.

terminal: sudo nano /etc/init/mysql.conf

GUI: gksudo gedit /etc/init/mysql.conf

This simple hack should now prevent MySQL from starting the next time you boot the computer.  Saves you a few seconds of boot time and lets you get to the desktop faster.

Note that I’ve only tested this hack on Ubuntu 10.04 Lucid Lynx. It might work on older versions as far back as 2007 when Ubuntu 7.04 Feisty Fawn was released (but who still uses Feisty?!). Oddly enough I just heard about this Upstart boot process that replaced the legacy SysVinit.  Then again, perhaps I’m not just familiar enough with the Ubuntu way after being away from it, and Linux in general, for over a year.  And between 2007 and the earlier parts of 2009, I was still using SuSE and Mandriva.

Update:

The correct way to stop services from being started by Upstart is to create an override file. This only works with Upstart version starting with Natty Narwhal. The procedure is straight to the point. In our case here, we have MySQL. Create an override file with the same name as the service and end it with .override. As root (use sudo) follow the steps below:

1) cd /etc/init

2) sudo touch mysql.override

3) sudo nano mysql.override

type “manual” inside the override file excluding the quotes
save the file then exit

Done!

Note that the above is the long way of doing it. You can alternately do “echo manual >> /etc/init/mysql.override” but for some reason I get a permission denied error when doing it with sudo.

Similar Posts: