mysql不会启动Ubuntu 16.04.2 x64

时间:2017-09-27 10:28:29

标签: mysql ubuntu ubuntu-16.04 apparmor

因此,服务器重启后MySQL不会重启/启动。没有编辑配置文件/进行任何更改。 我遇到与此question相同的问题,其中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

将这些执行添加到/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

然后以root身份: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,但是,我有没有备份的数据:(请帮忙

2 个答案:

答案 0 :(得分:0)

您是否尝试过ubuntu 16.04及更高版本

  sudo systemctl start mysql

答案 1 :(得分: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。