MySQL para de funcionar automaticamente ou reinicia

MySQL para de funcionar automaticamente ou reinicia

O MySQL parou de funcionar automaticamente ou foi reiniciado. Aqui estão os detalhes:

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)

Responder1

Em relação aos erros "Opção encontrada sem grupo anterior no arquivo de configuração", verifique o seguinte:

https://stackoverflow.com/questions/8020297/mysql-my-cnf-file-found-option-without-preceding-group

Aparentemente, pode haver algo errado com a codificação do arquivo de configuração do MySQL.

Se esse serviço ainda se recusar a iniciar depois, tentaremos corrigir as mensagens "AVC apparmor = "DENIED". Aqui, uma solução rápida e suja seria simplesmente desligá-lo:

systemctl stop apparmor
systemctl disable apparmor

informação relacionada