0

所以 MySQL 在服务器重启后不会重启/启动。未编辑任何配置文件/进行任何更改。我和这个问题有同样的问题,apparmor 导致了这些日志条目:

Sep 27 11:18:53 staging audit[2986]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/2986/status" pid=2986 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid=112
Sep 27 11:18:53 staging audit[2986]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=2986 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid=0
Sep 27 11:18:53 staging audit[2986]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/2986/status" pid=2986 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=112 ouid=112

当这些 execptions 添加到/etc/apparmor.d/usr.sbin.mysqld as 时:

# fix issue with mysql not restarting
  /proc/*/status r,
  /sys/devices/system/node/ r,
  /sys/devices/system/node/node0/meminfo r,
# Allow network access

然后作为根:service apparmor reload; service mysql restart;

日志现在只显示:

Sep 27 11:25:10 staging 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.
Sep 27 11:25:10 staging systemd[1]: mysql.service: Unit entered failed state.
Sep 27 11:25:10 staging systemd[1]: mysql.service: Failed with result 'exit-code'.
Sep 27 11:25:10 staging systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Sep 27 11:25:10 staging 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.
Sep 27 11:25:10 staging 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.
Sep 27 11:25:11 staging systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

我没有进行任何配置更改,所以我真的不知道该去哪里找。我打算重新安装 MySQL,但是,我有我没有备份的数据:(请帮助

4

2 回答 2

0

所以我设法让它工作,虽然我不知道它是如何工作的,但我跑了: apt-get remove mysql*; apt-get install mysql-server mysql-client ; 第一次我仍然无法启动 mysql。然后我再次运行它,mysql又开始工作了。我还能够删除这些行:

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

/etc/apparmor.d/usr.sbin.mysqld并重新加载apparmor。

于 2017-09-27T12:18:09.757 回答
0

你有没有为 ubuntu 16.04 及更高版本尝试过这个

  sudo systemctl start mysql
于 2017-09-27T10:35:06.847 回答