Ubuntu 的版本:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.2 LTS
Release: 20.04
Codename: focal
我在启动 mysql 时遇到问题,我尝试时总是出现以下消息:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xe" for details.
mysqld.log
我尝试使用命令检查tail -f /var/log/mysqld.log
,但似乎没有。
因此我尝试检查systemctl status mysql.service
并出现了以下情况:
mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; disabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2021-06-07 11:56:52 -03; 5h 18min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 8885 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=1/FAILURE)
jun 07 11:56:52 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
jun 07 11:56:52 mauriciojr27-Inspiron-3442 systemd[1]: Stopped MySQL Community Server.
jun 07 11:56:52 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Start request repeated too quickly.
jun 07 11:56:52 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Failed with result 'exit-code'.
jun 07 11:56:52 mauriciojr27-Inspiron-3442 systemd[1]: Failed to start MySQL Community Server.
我的mysql.cnf
文件配置如下:
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
#
# IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#
!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
此外,我尝试安装并删除 MySQL APT 存储库,但出现以下消息:
Error while installing package: the subprocess installed, package mysql-common, script post-installation return the error status exit 2
命令输出sudo journalctl -u mysql.service -n 100
:
-- Logs begin at Sat 2021-01-09 07:11:57 -03, end at Mon 2021-06-07 17:52:46 -03. --
jun 07 10:37:25 mauriciojr27-Inspiron-3442 systemd[1]: Starting MySQL Community Server...
jun 07 10:37:25 mauriciojr27-Inspiron-3442 mysql-systemd-start[73897]: MySQL configuration not found at /etc/mysql/my.cnf>
jun 07 10:37:25 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILU>
jun 07 10:37:25 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Failed with result 'exit-code'.
jun 07 10:37:25 mauriciojr27-Inspiron-3442 systemd[1]: Failed to start MySQL Community Server.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 3.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: Stopped MySQL Community Server.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: Starting MySQL Community Server...
jun 07 10:37:26 mauriciojr27-Inspiron-3442 mysql-systemd-start[73936]: MySQL configuration not found at /etc/mysql/my.cnf>
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILU>
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Failed with result 'exit-code'.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: Failed to start MySQL Community Server.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 4.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: Stopped MySQL Community Server.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: Starting MySQL Community Server...
jun 07 10:37:26 mauriciojr27-Inspiron-3442 mysql-systemd-start[73975]: MySQL configuration not found at /etc/mysql/my.cnf>
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Control process exited, code=exited, status=1/FAILU>
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Failed with result 'exit-code'.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: Failed to start MySQL Community Server.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: Stopped MySQL Community Server.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Start request repeated too quickly.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: mysql.service: Failed with result 'exit-code'.
jun 07 10:37:26 mauriciojr27-Inspiron-3442 systemd[1]: Failed to start MySQL Community Server.
-- Reboot --
jun 07 11:56:50 mauriciojr27-Inspiron-3442 systemd[1]: Starting MySQL Community Server...
命令sudo tail -f /var/log/mysql/error.log
不返回任何内容
我怎样才能解决这个问题?
答案1
输出中清楚地显示了错误:
jun 07 10:37:25 mauriciojr27-Inspiron-3442 mysql-systemd-start[73897]: MySQL configuration not found at /etc/mysql/my.cnf>
您的系统尝试使用my.cnf
您提供的mysql.cnf
。尝试复制mysql.cnf
到my.cnf
并重新启动。