每次系统启动时如何让mysql启动?我需要在我有我的博客的专用服务器(ubuntu 发行版)中使用它,但是每次服务器出现故障时,启动 mysql 都会停止。顺便说一句,我只能使用命令行。
9 回答
update-rc.d允许在 Ubuntu 和 Debian Linux 系统上设置初始化脚本链接,以控制在进入各种运行级别时由 init 运行哪些服务。它应该能够将 mysql 添加到启动时运行的服务列表中:
sudo update-rc.d mysql defaults
如果您以后想在启动时禁用正在运行的 mysql:
sudo update-rc.d mysql remove
您可以使用sysv-rc-conf
, 在基于 debian 的基础上安装它,sudo apt-get install sysv-rc-conf
然后您可以选择启动时在守护进程名称上使用简单 X 开始的内容,所有这些都通过命令行
运行以下命令以查看您的 mysql 当前状态:
/sbin/chkconfig mysqld --list
它将返回如下一行:
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off
要在每次系统启动时启动 mysql,请键入以下内容:
sudo /sbin/chkconfig mysqld on
现在来自“--list”的结果是:
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
没有答案有帮助。最后chkconfig
并update-rc.d
没有在我的机器上使用 MySQL。
解决方案,我有一个文件/etc/init/mysql.override其中包含
manual
我刚刚删除了那个文件
$ sudo rm /etc/init/mysql.override
我有同样的问题,所以我首先检查了我是如何禁用它的:
https://askubuntu.com/questions/138487/how-to-keep-apache-and-mysql-from-starting-automatically
检查您的 /etc/init/mysql.conf 以确保您没有开始注释掉(就像我一样)。
# MySQL Service
description "MySQL Server"
author "Mario Limonciello <superm1@ubuntu.com>"
start on runlevel [2345]
stop on starting rc RUNLEVEL=[016]
...
重新启动机器,它可以工作。
$ sudo service mysql status
mysql start/running, process 972
在我的情况下,删除 /etc/init/mysql.override 完成了这项工作(带有 Ubuntu 12.04 的 HostEurope VPS)
chkconfig
根据手册页http://manpages.ubuntu.com/manpages/maverick/man8/chkconfig.8.html使用命令
另一个寻找关于启动时启动和未启动的线索的地方......
/etc/init.d/.depend.start (以及它在关机时的伙伴,.depend.stop)
这里有更多信息http://www.pyenet.co.nz/2-202-1-customising-system-startup-and-boot-processes/
我有 2 台服务器 - 启动后,1 台会运行 mysql,而另一台则不会。
在启动时启动 mysql 的盒子上:
- chkconfig 甚至没有安装
- 从 /etc/rc?.d/* 中的任何脚本返回到 /etc/init.d/mysql 的链接为零
但是... /etc/init.d/.depend.start 包含:
TARGETS = halt apache2 umountfs umountnfs.sh sendsigs networking umountroot reboot killprocs unattended-upgrades urandom mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo postfix single grub-common ondemand rc.local INTERACTIVE = apache2 postfix: mysql single: killprocs dns-clean pppd-dns grub-common: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo ondemand: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo rc.local: apache2 unattended-upgrades postfix mysql mdadm dns-clean landscape-client pppd-dns sysstat rsync sudo
当我简单地将这个文件复制到问题服务器并重新启动时,mysql 已启动并运行。
使用 Debian 9,我今天安装了 MySQL 并输入“reboot”,mysqld 自动重新启动。也从我的 VPS 仪表板重新启动,mysqld 自动重新启动。简而言之,如果您拥有 Debian 9,则无需做任何额外的事情,它就可以工作。