MySQL 在 Ubuntu 17.10 上重启失败

MySQL 在 Ubuntu 17.10 上重启失败

我正在遵循这个指南:

http://kodi.wiki/view/MySQL/Setting_up_MySQL#tab=Ubuntu_Linux

目的是使用 mysql 网络文件共享,以便我可以在其他网络设备上安装的 Kodi 上查看 Raspberry Pi OSMC 上的媒体。我宁愿不使用 UPnP,因为它在 Kodi 中集成库的能力很差。

我在第 4 步收到以下失败消息:

$ sudo service mysql restart
[sudo] password for ms: 
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”和“journalctl -xe”的输出:

$ systemctl  status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
   Active: activating (start-post) (Result: exit-code) since Thu 2018-01-25 21:0
  Process: 2323 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 2317 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exit
 Main PID: 2323 (code=exited, status=1/FAILURE); Control PID: 2324 (mysql-system
    Tasks: 2 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─control
           ├─2324 /bin/bash /usr/share/mysql/mysql-systemd-start post
           └─2418 sleep 1

Jan 25 21:06:54 ms-ThinkPad-T530 systemd[1]: Starting MySQL Community Server...
Jan 25 21:06:56 ms-ThinkPad-T530 systemd[1]: mysql.service: Main process exited,
lines 1-14/14 (END)

进而:

$ journalctl  -xe
Jan 25 21:17:04 ms-ThinkPad-T530 systemd[1]: mysql.service: Unit entered failed state.
Jan 25 21:17:04 ms-ThinkPad-T530 systemd[1]: mysql.service: Failed with result 'exit-code'.
Jan 25 21:17:04 ms-ThinkPad-T530 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jan 25 21:17:04 ms-ThinkPad-T530 systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has finished shutting down.
Jan 25 21:17:04 ms-ThinkPad-T530 systemd[1]: Starting MySQL Community Server...
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has begun starting up.
Jan 25 21:17:04 ms-ThinkPad-T530 audit[4291]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="
Jan 25 21:17:04 ms-ThinkPad-T530 audit[4291]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="
Jan 25 21:17:04 ms-ThinkPad-T530 audit[4291]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="
Jan 25 21:17:04 ms-ThinkPad-T530 kernel: audit: type=1400 audit(1516911424.598:104): apparmor="DENIED" operation="open
Jan 25 21:17:04 ms-ThinkPad-T530 kernel: audit: type=1400 audit(1516911424.598:105): apparmor="DENIED" operation="open
Jan 25 21:17:04 ms-ThinkPad-T530 kernel: audit: type=1400 audit(1516911424.598:106): apparmor="DENIED" operation="open
Jan 25 21:17:06 ms-ThinkPad-T530 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE 

有人知道我该如何解决这个问题吗?

答案1

尝试编辑/etc/apparmor.d/usr.sbin.mysqld并添加以下行:

/proc/*/status r,
/sys/devices/system/node/ r,
/sys/devices/system/node/node0/meminfo r,

您的journalctl -xe输出被截断了,所以我只能猜测它试图访问的文件。它要访问的文件和目录的名称位于该name="部分之后。您可以随时重新发布您的输出journalctl -xe,我可以进一步帮助您。

AppArmor 配置文件有 2 点需要注意。r,行末的 表示授予读取权限。/第二行末尾的 表示您授予的是目录的读取权限,而不仅仅是文件的读取权限。

最后,让我们重新开始几件事:

sudo service apparmor reload
sudo service mysql restart

PS,您/var/log/syslog可以提供有关 MySQL 和 AppArmor 遇到问题的文件的其他信息。

PPS,这个文章Jeremy Smyth 的文章可能对你有用。它建议了几种我在这里没有介绍的修复/诊断问题的其他方法。

相关内容