无法安装 mysql,出现无法读取‘/etc/mysql/conf.d/’目录错误

无法安装 mysql,出现无法读取‘/etc/mysql/conf.d/’目录错误

我刚刚在 usb 上安装了最新版本的 ubuntu。首先我运行 sudo apt update,然后运行 ​​sudo apt install apache2。到目前为止一切都很好。但是当我运行时,sudo apt install mysql-server我收到此错误:

Setting up mysql-server-5.7 (5.7.24-0ubuntu0.18.04.1) ... Renaming removed key_buffer and myisam-recover options (if present) ERROR:
Unable to start MySQL server: mysqld: Can't read dir of '/etc/mysql/conf.d/' (Errcode: 13 - Permission denied) mysqld: [ERROR] Fatal error in defaults handling. Program aborted!

我在这里迷路了。我运行了sudo chmod -R 755 /etc/mysql/conf.d/,但没用。这可能是什么原因,为什么如果我 chmod 了目录,它会显示权限被拒绝?

的输出ls -lhd /etc/mysql/conf.ddrwxr-xr-x 2 root root 4.0K nov 10 20:55 /etc/mysql/conf.d

更新 重新启动笔记本电脑并运行 sudo apt install mysql-server 后,权限错误不再出现,但现在我收到另一个错误

ubuntu@ubuntu:~$ journalctl -xe An error was encountered while opening
journal file or directory
/var/log/journal/d83633b7cd754897927e2a87e67fd985/system@7f9cc60cd768485c982d8183c054e0ba-0000000000000001-00057a56ce4251c4.journal,
ignoring file: Identifier removed
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Automatic restarting of the unit mysql.service has been scheduled, as the res
-- the configured Restart= setting for the unit. nov 10 22:24:49 ubuntu systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has finished shutting down. nov 10 22:24:49 ubuntu systemd[1]: mysql.service: Start request repeated too qui nov
10 22:24:49 ubuntu systemd[1]: mysql.service: Failed with result
'exit-code' nov 10 22:24:49 ubuntu systemd[1]: Failed to start MySQL
Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has failed.
-- 
-- The result is RESULT. nov 10 22:24:54 ubuntu sudo[2810]: pam_unix(sudo:session): session closed for us lines 1129-1151/1151
(END)
-- Subject: Automatic restarting of a unit has been scheduled
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Automatic restarting of the unit mysql.service has been scheduled, as the result for
-- the configured Restart= setting for the unit. nov 10 22:24:49 ubuntu systemd[1]: Stopped MySQL Community Server.
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has finished shutting down. nov 10 22:24:49 ubuntu systemd[1]: mysql.service: Start request repeated too quickly.
nov 10 22:24:49 ubuntu systemd[1]: mysql.service: Failed with result
'exit-code'. nov 10 22:24:49 ubuntu systemd[1]: Failed to start MySQL
Community Server.
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
-- 
-- Unit mysql.service has failed.
-- 
-- The result is RESULT. nov 10 22:24:54 ubuntu sudo[2810]: pam_unix(sudo:session): session closed for user root

答案1

毕竟,我将 Ubuntu 安装到硬盘上而不是从 USB 运行它,之后一切都顺利进行。

答案2

我最近在将服务器升级到 18.04 时遇到了 apparmor 和 mysql 的问题。我的印象是,在安装/升级 mysql-server 时没有正确添加 apparmor 规则。

为了快速检查,您可以禁用 apparmor 并查看其是否有效:

sudo systemctl stop apparmor.service

如果是这种情况,你可能需要手动修复 apparmor 规则/etc/apparmor.d/usr.sbin.mysqld,具体到你的情况

  /etc/mysql/** r,

希望这可以帮助!

答案3

仅供参考:

停止装甲:

sudo /etc/init.d/apparmor stop
sudo /etc/init.d/apparmor teardown

创建一个空文件/etc/apparmor.d/usr.sbin.mysqld

清理所有 dpkg 包并重新运行安装。

当出现以下提示时,请确保选择

Configuration file '/etc/apparmor.d/usr.sbin.mysqld'
 ==> File on system created by you or by a script.
 ==> File also in package provided by package maintainer.
   What would you like to do about it ?  Your options are:
    Y or I  : install the package maintainer's version
    N or O  : keep your currently-installed version
      D     : show the differences between the versions
      Z     : start a shell to examine the situation
 The default action is to keep your current version.
*** usr.sbin.mysqld (Y/I/N/O/D/Z) [default=N] ? Y

(我成功了)

相关内容