
在全新安裝的 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
我在最後一步收到錯誤 - 重新啟動服務,但無法執行此操作。
我還在 mysql apparmor 設定檔中新增了 /sys/devices/system/node/ r 和 /sys/devices/system/node/** r ,因為它們不存在似乎是個錯誤: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答案...解決了我的問題。即使我不明白為什麼這兩個參數首先在那裡,因為這是一個乾淨的安裝?