mysql安装失败

ibrsph3r  于 2021-06-24  发布在  Mysql
关注(0)|答案(1)|浏览(523)

我在启动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

其他人似乎也有同样的问题,但迄今为止我发现的解决方案都不管用。例如,有人说他们的问题是由一个丢失的日志文件引起的,这个文件对我来说不是丢失的。

emeijp43

emeijp431#

感谢迈克尔o。至于评论,它帮了我很大的忙。他自己链接的问题的答案并没有解决我的问题,因为在将mysql列入白名单以访问它需要的文件之后,apparmor开始阻止mysql获取功能。
在搜索时,我看到了一篇来自oracle的博客文章,其中建议使用 apparmor-utils 的实用程序调用 aa-complain . 这个实用程序设置一个配置文件到投诉模式,基本上让你一个警告。
所以我安装了 apparmor-utils :

sudo apt install apparmor-utils

已检查mysql服务的位置:

which mysql

并使用输出将服务置于投诉模式:

aa-complain /usr/bin/mysql

重新启动计算机后,服务将正常启动。

相关问题