它昨天突然坏了(无法再启动)而且我不知道如何修理它。
当我跑步时:
sudo service mysql start
它给出了这个错误:
Job for mysql.service failed because the control process exited with error
code. See "systemctl status mysql.service" and "journalctl -xe" for details.
输出systemctl status mysql.service
:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)<br>
Active: inactive (dead) (Result: exit-code) since Mon 2016-09-05 15:10:31 CEST; 43s ago<br>
Process: 6515 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)<br>
Sep 05 15:10:31 vps310084 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.<br>
Sep 05 15:10:31 vps310084 systemd[1]: Stopped MySQL Community Server.<br>
Sep 05 15:10:31 vps310084 systemd[1]: mysql.service: Start request repeated too quickly.<br>
Sep 05 15:10:31 vps310084 systemd[1]: Failed to start MySQL Community Server.<br>
Sep 05 15:10:33 vps310084 systemd[1]: mysql.service: Start request repeated too quickly.<br>
Sep 05 15:10:33 vps310084 systemd[1]: Failed to start MySQL Community Server.
输出journalctl -xe
:
Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel**
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Sep 05 15:14:56 vps310084 systemd[1]: mysql.service: Unit entered failed state.
Sep 05 15:14:56 vps310084 systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 05 15:14:56 vps310084 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 05 15:14:56 vps310084 systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down<br>
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Sep 05 15:14:56 vps310084 systemd[1]: mysql.service: Start request repeated too quickly.
Sep 05 15:14:56 vps310084 systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
--
-- Unit mysql.service has failed.
--
-- The result is failed.
答案1
Mysql 的 systemctl 启动脚本无法运行此命令 /usr/share/mysql/mysql-systemd-start pre
除了使用以下 shell 代码检查你的环境之外,这没有什么用:
sanity () {
if [ ! -r /etc/mysql/my.cnf ]; then
echo "MySQL configuration not found at /etc/mysql/my.cnf. Please create one."
exit 1
fi
if [ ! -d /var/lib/mysql ] && [ ! -L /var/lib/mysql ]; then
echo "MySQL data dir not found at /var/lib/mysql. Please create one."
exit 1
fi
if [ ! -d /var/lib/mysql/mysql ] && [ ! -L /var/lib/mysql/mysql ]; then
echo "MySQL system database not found. Please run mysql_install_db tool."
exit 1
fi
}
如果您直接通过 sudo 运行它,您应该会收到其中一条错误消息,请按照其建议进行操作并重试,直到它起作用为止。
这不是一个随机损坏,这是缺少文件,请检查 root 用户以及任何可以 sudo 的用户的 bash_history。