MySQL 自动停止工作或重新启动。以下是详细信息:
root@ubuntu-s-1vcpu-1gb-blr1-01:~# Process: 8233 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
-bash: syntax error near unexpected token `('
root@ubuntu-s-1vcpu-1gb-blr1-01:~# sudo service mysql restart
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
root@ubuntu-s-1vcpu-1gb-blr1-01:~# systemctl status mysql.service
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (start-post) (Result: exit-code) since Wed 2019-11-06 09:47:05 UTC; 21s ago
Process: 9033 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 9025 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 9033 (code=exited, status=1/FAILURE); : 9034 (mysql-systemd-s)
Tasks: 2
Memory: 308.0K
CPU: 137ms
CGroup: /system.slice/mysql.service
└─control
├─9034 /bin/bash /usr/share/mysql/mysql-systemd-start post
└─9080 sleep 1
Nov 06 09:47:05 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: Starting MySQL Community Server...
Nov 06 09:47:05 ubuntu-s-1vcpu-1gb-blr1-01 mysql-systemd-start[9025]: my_print_defaults: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22
Nov 06 09:47:05 ubuntu-s-1vcpu-1gb-blr1-01 mysql-systemd-start[9025]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Nov 06 09:47:05 ubuntu-s-1vcpu-1gb-blr1-01 mysqld[9033]: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22!
Nov 06 09:47:05 ubuntu-s-1vcpu-1gb-blr1-01 mysqld[9033]: mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Nov 06 09:47:05 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
lines 1-20/20 (END)
root@ubuntu-s-1vcpu-1gb-blr1-01:~# journalctl -xe
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 mysql-systemd-start[9105]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 kernel: audit: type=1400 audit(1573033656.481:277): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/9113/sta
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 audit[9113]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/9113/status" pid=9113 comm="mysqld" request
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 audit[9113]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=9113 comm="mysqld"
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 kernel: audit: type=1400 audit(1573033656.485:278): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/s
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 kernel: audit: type=1400 audit(1573033656.485:279): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/9113/sta
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 audit[9113]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/9113/status" pid=9113 comm="mysqld" request
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 mysqld[9113]: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22!
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 mysqld[9113]: mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Nov 06 09:47:36 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Nov 06 09:47:39 ubuntu-s-1vcpu-1gb-blr1-01 sshd[9124]: Invalid user from 80.211.41.73
Nov 06 09:47:39 ubuntu-s-1vcpu-1gb-blr1-01 sshd[9124]: input_userauth_request: invalid user [preauth]
Nov 06 09:47:39 ubuntu-s-1vcpu-1gb-blr1-01 sshd[9124]: pam_unix(sshd:auth): check pass; user unknown
Nov 06 09:47:39 ubuntu-s-1vcpu-1gb-blr1-01 sshd[9124]: pam_unix(sshd:auth): authentication failure; logname= uid=0 euid=0 tty=ssh ruser= rhost=80.211.41.73
Nov 06 09:47:41 ubuntu-s-1vcpu-1gb-blr1-01 sshd[9124]: Failed password for invalid user from 80.211.41.73 port 50690 ssh2
Nov 06 09:47:41 ubuntu-s-1vcpu-1gb-blr1-01 sshd[9124]: Received disconnect from 80.211.41.73 port 50690:11: Bye Bye [preauth]
Nov 06 09:47:41 ubuntu-s-1vcpu-1gb-blr1-01 sshd[9124]: Disconnected from 80.211.41.73 port 50690 [preauth]
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: Failed to start MySQL Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has failed.
--
-- The result is failed.
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: mysql.service: Unit entered failed state.
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: mysql.service: Failed with result 'exit-code'.
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has finished shutting down.
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysql.service has begun starting up.
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 mysql-systemd-start[9185]: my_print_defaults: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 mysql-systemd-start[9185]: my_print_defaults: [ERROR] Fatal error in defaults handling. Program aborted!
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 audit[9193]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/9193/status" pid=9193 comm="mysqld" request
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 audit[9193]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=9193 comm="mysqld"
Nov 06 09:48:06 ubuntu-s-1vcpu-1gb-blr1-01 audit[9193]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/9193/status" pid=9193 comm="mysqld" request
Nov 06 09:48:07 ubuntu-s-1vcpu-1gb-blr1-01 kernel: audit: type=1400 audit(1573033686.997:280): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/9193/sta
Nov 06 09:48:07 ubuntu-s-1vcpu-1gb-blr1-01 kernel: audit: type=1400 audit(1573033686.997:281): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/s
Nov 06 09:48:07 ubuntu-s-1vcpu-1gb-blr1-01 kernel: audit: type=1400 audit(1573033686.997:282): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/9193/sta
Nov 06 09:48:07 ubuntu-s-1vcpu-1gb-blr1-01 mysqld[9193]: mysqld: [ERROR] Found option without preceding group in config file /etc/mysql/my.cnf at line 22!
Nov 06 09:48:07 ubuntu-s-1vcpu-1gb-blr1-01 mysqld[9193]: mysqld: [ERROR] Fatal error in defaults handling. Program aborted!
Nov 06 09:48:07 ubuntu-s-1vcpu-1gb-blr1-01 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
lines 2057-2107/2107 (END)
答案1
关于“在配置文件中找到没有前面组的选项”错误,请查看以下内容:
https://stackoverflow.com/questions/8020297/mysql-my-cnf-file-found-option-without-preceding-group
显然,您的 MySQL 配置文件编码可能有问题。
如果该服务之后仍然拒绝启动,我们接下来将尝试修复“AVC apparmor=”DENIED”消息。在这里,一个快速而粗略的修复方法是将其关闭:
systemctl stop apparmor
systemctl disable apparmor