移动数据后 Mysql 无法启动,缺少 sock 文件

移动数据后 Mysql 无法启动,缺少 sock 文件

在全新安装的 Ubuntu 16.04 和全新安装的 mysql 中,我以类似的方式移动了我的 mysql 数据然而发布之后,当我尝试重新启动/启动 mysql 时,我得到:

error: can't connect to local MySQL server throught socket '/var/run/mysqld/mysql.sock' (2) 
Check that mysqld is running and that the socket: '/var/run/mysqld/mysql.sock' exists!

文件夹 /var/run/mysqld 存在,但文件不存在。

当我运行时:find / -type s文件 mysql.sock 不在列表中。


的结果journalctl -xe

-- Unit mysql.service has finished shutting down.
Jun 12 11:45:16 wkssop-hev7 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.
Jun 12 11:45:16 wkssop-hev7 audit[5882]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5882/status" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=110
Jun 12 11:45:16 wkssop-hev7 audit[5882]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=0
Jun 12 11:45:16 wkssop-hev7 audit[5882]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5882/status" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=110
Jun 12 11:45:16 wkssop-hev7 kernel: audit: type=1400 audit(1497260716.044:133): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5882/status" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=110
Jun 12 11:45:16 wkssop-hev7 kernel: audit: type=1400 audit(1497260716.044:134): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=0
Jun 12 11:45:16 wkssop-hev7 kernel: audit: type=1400 audit(1497260716.044:135): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/5882/status" pid=5882 comm="mysqld" requested_mask="r" denied_mask="r" fsuid=110 ouid=110
Jun 12 11:45:17 wkssop-hev7 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

结果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 Mon 2017-06-12 11:45:46 CEST; 6s ago
  Process: 5986 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 5978 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 5986 (code=exited, status=1/FAILURE);         : 5987 (mysql-systemd-s)
    Tasks: 2
   Memory: 1.4M
      CPU: 259ms
   CGroup: /system.slice/mysql.service
           └─control
             ├─5987 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─6029 sleep 1

Jun 12 11:45:46 wkssop-hev7 systemd[1]: Starting MySQL Community Server...
Jun 12 11:45:48 wkssop-hev7 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

这基本上是我正在遵循的步骤:

if ! service mysql stop ; then
   echo "ignoring failure to stop mysql"
fi

cp config/my.cnf /etc/mysql/my.cnf
mkdir -p /data/mysqldata
chmod 777 /data/mysqldata
cp -R -p /var/lib/mysql/* /data/mysqldata

sed "s/\/var\/lib\/mysql/\/data\/mysqldata/g" /etc/apparmor.d/usr.sbin.mysqld > tmp
mv tmp /etc/apparmor.d/usr.sbin.mysqld
apparmor_parser -r /etc/apparmor.d/usr.sbin.mysqld
/etc/init.d/apparmor reload
service mysql restart

我在最后一步重新启动服务时出现错误,但无法执行此操作。

我还将 /sys/devices/system/node/r 和 /sys/devices/system/node/** r 添加到了 mysql apparmor 配置文件中,因为它们不存在似乎是一个错误:https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1658233

但是现在我想知道我是否应该对 /proc/####/status 执行相同操作,嗯,我猜它实际上必须是 /proc?所以我虽然也可以尝试一下,但仍然失败。

journatlctl -xe | tail -30:

-- 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.
Jun 14 13:28:50 minint-l35opp1 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Jun 14 13:29:18 minint-l35opp1 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.
Jun 14 13:29:18 minint-l35opp1 systemd[1]: mysql.service: Unit entered failed state.
Jun 14 13:29:18 minint-l35opp1 systemd[1]: mysql.service: Failed with result 'exit-code'.
Jun 14 13:29:18 minint-l35opp1 systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Jun 14 13:29:18 minint-l35opp1 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.
Jun 14 13:29:18 minint-l35opp1 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.
Jun 14 13:29:20 minint-l35opp1 systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE

答案1

我遇到的最后一个错误导致我出现这种情况:https://askubuntu.com/a/792857/693474答案......这解决了我的问题。尽管我不明白为什么这两个参数首先出现在那里,因为这是一个全新安装?

相关内容