彻底关闭mysql service,禁止开机自动运行

1)正常 disable service autorun的方法,例如禁用mysql:

[sourcecode language=”plain”]
# ls -l /etc/rc?.d/*apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc0.d/K91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc1.d/K91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc2.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc3.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc4.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc5.d/S91apache2 -> ../init.d/apache2
lrwxrwxrwx 1 root root 17 2007-07-05 22:51 /etc/rc6.d/K91apache2 -> ../init.d/apache2
[/sourcecode]
[sourcecode language=”plain”]
# update-rc.d -f apache2 remove
[/sourcecode]

将上面的apache2 换成 mysql 即可。
2)mysql 通过上面方法后,发现mysql service仍然启动运行,原因是因为linux runlevel,解决方法如下:
我们看/etc/init/mysql.conf里面的定义

[sourcecode language=”plain”]
start on (net-device-up
and local-filesystems
and runlevel [2345])
stop on runlevel [016]
[/sourcecode]

从这里我们可以读到,runrevel为2345时,mysql是启动的,唯独016是不启动的

直接注释掉了启动的那行,而stop里面为0123456(这句不改也可以)

[sourcecode language=”plain”]
start on (net-device-up
and local-filesystems)
#      and runlevel [2345])
stop on runlevel [0123456]
[/sourcecode]

留言