我在启动MySQL服务时遇到问题所以我删除了这样的软件包:
sudo dpkg -P mysql-server mysql-server-5.7
sudo apt autoremove
sudo apt clean
sudo rm -rvf /var/lib/mysql
sudo apt install mysql-server
在安装过程中,我被要求输入root的密码,之后发生了以下情况:
Setting up mysql-server-5.7 (5.7.21-0ubuntu0.16.04.1) ...
Renaming removed key_buffer and myisam-recover options (if present)
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since Mo 2018-04-23 17:22:42 CEST; 6ms ago
Process: 27860 ExecStartPost=/usr/share/mysql/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 27859 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
Process: 27851 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 27859 (code=exited, status=1/FAILURE)
Apr 23 17:22:42 mari systemd[1]: Failed to start MySQL Community Server.
Apr 23 17:22:42 mari systemd[1]: mysql.service: Unit entered failed state.
Apr 23 17:22:42 mari systemd[1]: mysql.service: Failed with result 'exit-code'.
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-server-5.7
mysql-server
运行dpkg --configure -a
会导致相同的错误。这是journalctl -xe
:
-- 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.
Apr 23 17:25:20 mari audit[28913]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28913/status" pid=28913 comm="mysqld
Apr 23 17:25:20 mari audit[28913]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=28913 comm=
Apr 23 17:25:20 mari audit[28913]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28913/status" pid=28913 comm="mysqld
Apr 23 17:25:20 mari kernel: audit: type=1400 audit(1524497120.211:209): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/28
Apr 23 17:25:22 mari systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
Apr 23 17:25:50 mari 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.
Apr 23 17:25:50 mari systemd[1]: mysql.service: Unit entered failed state.
Apr 23 17:25:50 mari systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 23 17:25:50 mari sudo[28755]: pam_unix(sudo:session): session closed for user root
Apr 23 17:25:50 mari systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 23 17:25:50 mari 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.
Apr 23 17:25:50 mari 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.
Apr 23 17:25:50 mari audit[29041]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29041/status" pid=29041 comm="mysqld
Apr 23 17:25:50 mari audit[29041]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/devices/system/node/" pid=29041 comm=
Apr 23 17:25:50 mari audit[29041]: AVC apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29041/status" pid=29041 comm="mysqld
Apr 23 17:25:50 mari kernel: kauditd_printk_skb: 2 callbacks suppressed
Apr 23 17:25:50 mari kernel: audit: type=1400 audit(1524497150.668:212): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29
Apr 23 17:25:50 mari kernel: audit: type=1400 audit(1524497150.668:213): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/sys/dev
Apr 23 17:25:50 mari kernel: audit: type=1400 audit(1524497150.668:214): apparmor="DENIED" operation="open" profile="/usr/sbin/mysqld" name="/proc/29
Apr 23 17:25:52 mari systemd[1]: mysql.service: Main process exited, code=exited, status=1/FAILURE
其他人似乎也有同样的问题,但到目前为止我找到的解决方案都没有。例如,有人说他们的问题是由于缺少日志文件引起的,这对我来说并不缺失。
答案 0 :(得分:1)
感谢Michael O.的评论,这对我帮助很大。他自己联系的问题的答案并没有解决我的问题,因为在将MySQL列入白名单以访问所需的文件后,apparmor开始阻止MySQL获取功能。
在搜索时,我发现this blog post from Oracle建议使用名为apparmor-utils
的{{1}}实用程序。此实用程序将配置文件设置为投诉模式,基本上让您关闭并发出警告。
所以我安装了aa-complain
:
apparmor-utils
检查MySQL服务的位置:
sudo apt install apparmor-utils
并使用输出将服务置于抱怨模式:
which mysql
重新启动计算机后,服务启动时没有错误。