Configure MySQL and Apache not to start at boot on Ubuntu Linux

MySQL logoI often do my web development on the move using my laptop. Because of that I must run Apache with PHP and MySQL servers on both my desktop and my laptop PC. You can probably guess that this doesn't help to conserve my laptop battery so I've configured my laptop not to start MySQL and Apache automatically at boot. Instead I start those services manually when I plan to do some coding. In this article I'll show you how to configure your Ubuntu based PC to do the same.

Process of configuring Apache web server not to start at boot is pretty straightforward. We can use Debian's upadate-rc.d to disable Apache service like this:

sudo update-rc.d -f apache2 remove

That's it for Apache. From now on to start Apache web server you can use following command:

sudo service apache2 start

Configuring MySQL not to start at boot is just a little more complicated but also straightforward. First open mysql.conf file with root privileges using your favorite text editor. Here's how to do this using Gedit:

gksudo gedit /etc/init/mysql.conf

Now find following four lines at the beginning of this file:

start on (net-device-up
          and local-filesystems
	  and runlevel [2345])
stop on runlevel [016]

To configure MySQL not to start at boot you should add comment sign # at the beginning of the first three lines like this:

#start on (net-device-up
#          and local-filesystems
#	  and runlevel [2345])
stop on runlevel [016]

That's it for the MySQL server. Now you can start it manually using following command:

sudo service mysql start

Easy but useful wasn't it?


A quality focused Magento specialized web development agency. Get in touch!

10 thoughts on “Configure MySQL and Apache not to start at boot on Ubuntu Linux

    1. Marko Author

      Hello Ben. For Apache 2 you just do sudo update-rc.d apache2 defaults and for MySQL do reverse from this article, comment out three lines from /etc/init/mysql.conf) 😉

  1. Bart Willemsen

    Great little guide! Thanks! Just one thing to keep in mind though.. it looks like you have to run that command to stop Apache from starting automatically every time after an Apache update. Here it always gets reconfigured to auto start again after an update at least. 😛

  2. Dov

    I want to run a set of queries and then show the CPU time. If I were running apache manually, I would just write:

    time httpd

    Is there an easy way to run apache manually, or to be able to log output from the time command when I stop the service?

    Alternatively, is there an internal log to show me CPU utilization between two points in time?


Leave a Reply

Your email address will not be published. Required fields are marked *