how to stop apache2, mysql from starting automatically as computer starts?

45,623

Solution 1

MySQL is handled by upstart. In 11.04 you can use the new override feature to modify the starting behaviour:

echo "manual" >> /etc/init/mysql.override

See the section "Disabling a Job from Automatically Starting" in the Upstart Cookbook

Apache still uses traditional SysV init scripts so you use

 update-rc.d -f apache2 remove

to remove the links from /etc/rcX.d or, alternatively, use

 update-rc.d apache2 disable

which "disables" the script by changing it from a start script S91apache2 to a stop script K09apache2. This is reversible by update-rc.d apache2 enable.

Solution 2

Interestingly, it's a different answer for each package in 11.04.

  • apache2 uses System V style init scripts. To disable it from boot:
    sudo update-rc.d -f apache2 remove
  • However, mysql uses an Upstart job, to disable it, create an "override" file:
    echo "manual" | sudo tee /etc/init/mysql.override

To learn more about override files, see: The Upstart Cookbook

Solution 3

This thread will help you: https://superuser.com/questions/35151/how-do-i-stop-services-from-starting-on-boot-on-ubuntu

Solution 4

update-rc.d is a good CLI tool to do this. The linked page has an example involving apache2

Solution 5

It was't working for me. When trying to disable mysql in ubuntu I was receiving the message:

System start/stop links for /etc/init.d/mysql do not exist.

So I found a work around in this link: http://forum.linode.com/viewtopic.php?t=5594

sudo mkdir /etc/init.disabled

sudo mv /etc/init/mysql.conf /etc/init.disabled/

And that's it.

Share:
45,623

Related videos on Youtube

acapuster
Author by

acapuster

Live and let live :)

Updated on September 18, 2022

Comments

  • acapuster
    acapuster over 1 year

    My os is 11.04.

    I have apache2 & mysql installed.

    How to stop apache2, mysql from starting automatically as computer starts?

  • Christopher B. Adkins
    Christopher B. Adkins about 13 years
    This only works for services using SysV style init scripts. Ubuntu is switching to Upstart for most services so update-rc.d doesn't work anymore.
  • papukaija
    papukaija about 13 years
    Apache doesn't use upstart.
  • Christopher B. Adkins
    Christopher B. Adkins about 13 years
    Yes, my error - I converted it to use Upstart on my system...
  • acapuster
    acapuster about 13 years
    Got this error "bash: /etc/init/mysql.override: Permission denied" in both case
  • acapuster
    acapuster about 13 years
    @Florian: How did you convert? and whats the advantage of converting?
  • papukaija
    papukaija about 13 years
    @Rahul: You get the error as both the echo and the update-rc.d need to be run with sudo.
  • acapuster
    acapuster about 13 years
    $ sudo echo "manual" >> /etc/init/mysql.override
  • acapuster
    acapuster about 13 years
    Got error "bash: /etc/init/mysql.override: Permission denied"
  • Feras Kayyali
    Feras Kayyali about 13 years
    @RAHUL It can't work becouse redirection is created by bash before executing sudo - and that why the file is created as your user, not as a root. You can use such command: sudo su -c 'echo "manual" >> /etc/init/mysql.override'.
  • Christopher B. Adkins
    Christopher B. Adkins about 13 years
    @Rahul: To convert it you have to write a .conf file for upstart. I just did it to learn how it is done.
  • radek
    radek about 12 years
    @FlorianDiesch Will that work for 11.10 as well?
  • Christopher B. Adkins
    Christopher B. Adkins about 12 years
    @radek: Yes. That should work with any Ubuntu version that uses Upstart 1.3 or later.
  • yuvilio
    yuvilio almost 12 years
    I am using mariadb flavor of Mysql and found that it was still managed by sysvinit rather than Upstart. Removed it from startup by executing sudo update-rc.d -f mysql remove .
  • Tomasz Gandor
    Tomasz Gandor over 9 years
    @RahulPrasad @LukaszStelmach - this is a common pattern, but I hate sudo su -c 'quoted commands', you can just use tee, like in echo "manual" | sudo tee -a /etc/init/mysql.override. For > use just tee, for >> it's tee -a.