MySQL 安装未能在 Ubuntu 20.04 上正确完成

MySQL 安装未能在 Ubuntu 20.04 上正确完成

我尝试使用清除功能删除与旧安装相关的所有内容,包括配置。在我升级到 Ubuntu 20.04 并删除在 Ubuntu 18.04 中完成的旧 mysql 安装后,这种情况开始发生。

(编辑)很长时间后终端出现此错误:

Job for mysql.service failed because a timeout was exceeded.
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)
    Drop-In: /etc/systemd/system/mysql.service.d
             └─override.conf
     Active: activating (auto-restart) (Result: timeout) since Mon 2020-10-26 19
:06:58 PKT; 6ms ago
    Process: 103253 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=
exited, status=0/SUCCESS)
    Process: 103280 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysql
d/mysqld.pid --skip-grant-tables --skip-networking (code=exited, status=0/SUCCES
S)
   Main PID: 103280 (code=exited, status=0/SUCCESS)
     Status: "Server shutdown complete"
      Error: 2 (No such file or directory)

اکتوبر 26 19:06:58 in01-nbk-429 systemd[1]: mysql.service: Scheduled restart job
, restart counter is at 1.
اکتوبر 26 19:06:58 in01-nbk-429 systemd[1]: Stopped MySQL Community Server.
اکتوبر 26 19:06:58 in01-nbk-429 systemd[1]: Starting MySQL Community Server...
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned
 error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-8.0; however:
  Package mysql-server-8.0 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for systemd (245.4-4ubuntu3.2) ...
No apport report written because the error message indicates its a followup erro
r from a previous failure.
                          Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.1) ...
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
W: Operation was interrupted before it could finish

这是我安装过程中的终端输出,它在这里停了很长时间。

reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
emitting double-array: 100% |###########################################| 
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix      : 100% |###########################################| 

done!
update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/me
cab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my
.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 102997
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib
/systemd/system/mysql.service.
       

这是我的/var/log/mysql/error.log

2020-10-26T13:56:47.953648Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21-0ubuntu0.20.04.4) starting as process 102995
2020-10-26T13:56:47.988142Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-10-26T13:56:48.523413Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-10-26T13:56:48.704356Z 0 [ERROR] [MY-011292] [Server] Plugin mysqlx reported: 'Preparation of I/O interfaces failed, X Protocol won't be accessible'
2020-10-26T13:56:48.704600Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock'
2020-10-26T13:56:48.827698Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-10-26T13:56:48.827982Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2020-10-26T13:56:48.834057Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2020-10-26T13:56:48.872336Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21-0ubuntu0.20.04.4'  socket: '/tmp/tmp.cPePEr7iWv/mysqld.sock'  port: 0  (Ubuntu).
2020-10-26T13:56:48.926842Z 0 [System] [MY-013172] [Server] Received SHUTDOWN from user <via user signal>. Shutting down mysqld (Version: 8.0.21-0ubuntu0.20.04.4).
2020-10-26T13:56:50.282042Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.21-0ubuntu0.20.04.4)  (Ubuntu).
2020-10-26T13:56:51.586812Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21-0ubuntu0.20.04.4) starting as process 103061
2020-10-26T13:56:51.595462Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-10-26T13:56:52.057199Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-10-26T13:56:52.228093Z 0 [ERROR] [MY-011300] [Server] Plugin mysqlx reported: 'Setup of socket: '/var/run/mysqld/mysqlx.sock' failed, can't create lock file /var/run/mysqld/mysqlx.sock.lock'
2020-10-26T13:56:52.228512Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060
2020-10-26T13:56:52.334615Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-10-26T13:56:52.334923Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2020-10-26T13:56:52.347505Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/tmp' in the path is accessible to all OS users. Consider choosing a different directory.
2020-10-26T13:56:52.387655Z 7 [System] [MY-013172] [Server] Received SHUTDOWN from user boot. Shutting down mysqld (Version: 8.0.21-0ubuntu0.20.04.4).
2020-10-26T13:56:54.774192Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.21-0ubuntu0.20.04.4)  (Ubuntu).
2020-10-26T13:56:57.028746Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.21-0ubuntu0.20.04.4) starting as process 103271
2020-10-26T13:56:57.052635Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2020-10-26T13:56:57.522416Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2020-10-26T13:56:57.719154Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: /var/run/mysqld/mysqlx.sock
2020-10-26T13:56:57.876130Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-10-26T13:56:57.876430Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2020-10-26T13:56:57.890871Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.21-0ubuntu0.20.04.4'  socket: '/var/run/mysqld/mysqld.sock'  port: 0  (Ubuntu).

答案1

运行 apt update 后检查 /var/log/syslog。我遇到的问题和你类似,在我的系统日志中,我发现一些以 apparmor=”DENIED” operation=”open” profile=”/usr/sbin/mysqld” 开头的条目

如果启用了 AppArmor 并且 mysqld 处于强制模式,则可能会出现问题。运行这些命令将禁用 MySQL 的 AppArmor,然后我就可以更新 MySQL。

sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/disable/usr.sbin.mysqld

您可以在这里阅读有关我的故障排除的更多信息: Ubuntu 20.04 上的 MySQL 8.0 升级错误

相关内容