Start by understanding the change history of the following run-level corresponding tools:
1, Ubuntu 6.10 and previous versions use Sysvinit.
2, Ubuntu 14.10 and the previous version of the use of upstart but still keep sysvinit coexist.
Https://wiki.ubuntu.com/Upstart
Https://help.ubuntu.com/community/UpstartHowto
3, Ubuntu 15.04 started using SYSTEMD, but you can choose to use the SYSTEMD or upstart in the boot option, but not the same time using sysvinit or upstart coexist.
Https://wiki.ubuntu.com/SystemdForUpstartUsers
Here is the analysis:
from the 11.04 version, I think. MySQL is handled by upstart , while Apache still uses the traditional sysvinit script.
for MySQL, you can use The new overrides feature in upstart to modify the startup behavior:
Echo "Manual" | sudo tee/etc/init/mysql.override
For more information, see Upstart Cookbook in the " Disable Auto-start jobs " section .
In the 16.04 version, the above script cannot be used because the SYSTEMD is used to take over, so it is forbidden to use the following scripts:
#禁止启动
sudo systemctl disable MySQL
#开机启动
sudo systemctl enable MySQL
So, I guess, MySQL is now all handled by SYSTEMD, but this is limited to the version installed with the APT source and the Deb file, and the version that was installed in the binary package (tar.gz package) is still controlled using the Sysvinit script.
For SYSTEMD, services are much more streamlined at run-level, without worrying about which runlevel to run on. The default has been configured for you.
For Apache Analysis:
since Apache still uses the traditional Sysvinit script that you can use it
sudo update-rc.d-f apache2 Remove
Remove a link from /etc/rcX.d
or replace it with
sudo update-rc.d apache2 disable
It "disables" the script by changing the script from the start script to the stop scripts. This is reversible.
sudo update-rc.d apache2 enable
For the Sysvinit script operation, the corresponding tool is sysv-rc-conf.
参考:
Https://askubuntu.com/questions/40072/how-to-stop-apache2-mysql-from-starting-automatically-as-computer-starts
Https://askubuntu.com/questions/833094/how-can-i-disable-autostart-of-mysql-server
Https://askubuntu.com/questions/57381/how-to-stop-mysql-from-running-at-boot-time
https://askubuntu.com/questions/40072/how-to-stop-apache2-mysql-from-starting-automatically-as-computer-starts/40077#40077
Ubuntu 16.04 under MySQL 5.7.18 cancel boot start (fix cannot use Sysvinit (update-rc.d/sysv-rc-conf) script off)