Ubuntu20.04安裝MySQL8.0時出現依賴錯誤解決辦法

tcliuwenwen發表於2020-09-25

博文背景

在使用apt安裝mysql8.0時出現瞭如下的依賴報錯:

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
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

問題解決

作者先進行了換源,然後重新安裝,發現還是同樣的報錯,那麼說明不是源的問題,作者再檢視一下埠是否被佔用,發現3306埠被我的docker中的一個mysql容器給暴露出來了所以導致埠被佔用。

於是我關閉了docker,再次重新使用apt安裝MySQL8.0問題立馬得到解決。

日誌記錄

root@yellow:~# apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
mysql-server is already the newest version (8.0.21-0ubuntu0.20.04.4).
0 upgraded, 0 newly installed, 0 to remove and 114 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] Y
Setting up mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
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 402583
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
Errors were encountered while processing:
 mysql-server-8.0
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@yellow:~# apt purge mysql-
mysql-client-8.0       mysql-common           mysql-server-core-8.0
mysql-client-core-8.0  mysql-server
root@yellow:~# apt purge mysql-common
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libcgi-fast-perl libcgi-pm-perl libencode-locale-perl libevent-core-2.1-7 libfcgi-perl
  libhtml-parser-perl libhtml-tagset-perl libhtml-template-perl libhttp-date-perl
  libhttp-message-perl libio-html-perl liblwp-mediatypes-perl libmecab2 libtimedate-perl
  liburi-perl mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-core-8.0
  mysql-server-core-8.0
Use 'apt autoremove' to remove them.
The following packages will be REMOVED:
  mysql-client-8.0* mysql-common* mysql-server* mysql-server-8.0*
0 upgraded, 0 newly installed, 4 to remove and 114 not upgraded.
2 not fully installed or removed.
After this operation, 1,767 kB disk space will be freed.
Do you want to continue? [Y/n] Y
(Reading database ... 113032 files and directories currently installed.)
Removing mysql-server (8.0.21-0ubuntu0.20.04.4) ...
Removing mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Removing mysql-client-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Removing mysql-common (5.8+1.0.5ubuntu2) ...
Processing triggers for man-db (2.9.1-1) ...
(Reading database ... 112983 files and directories currently installed.)
Purging configuration files for mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Purging configuration files for mysql-common (5.8+1.0.5ubuntu2) ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed
Processing triggers for systemd (245.4-4ubuntu3) ...
root@yellow:~# ss -ntlp
State      Recv-Q     Send-Q                  Local Address:Port            Peer Address:Port     Process
LISTEN     0          4096                        127.0.0.1:45959                0.0.0.0:*         users:(("containerd",pid=2252,fd=6))
LISTEN     0          32                       10.236.187.1:53                   0.0.0.0:*         users:(("dnsmasq",pid=18295,fd=9))
LISTEN     0          4096                    127.0.0.53%lo:53                   0.0.0.0:*         users:(("systemd-resolve",pid=491,fd=13))
LISTEN     0          128                           0.0.0.0:22                   0.0.0.0:*         users:(("sshd",pid=672,fd=3))
LISTEN     0          128                         127.0.0.1:6010                 0.0.0.0:*         users:(("sshd",pid=285982,fd=10))
LISTEN     0          128                         127.0.0.1:6011                 0.0.0.0:*         users:(("sshd",pid=395705,fd=10))
LISTEN     0          4096                                *:3306                       *:*         users:(("docker-proxy",pid=15624,fd=4))
LISTEN     0          32             [fd42:2fe:1e1:9cb7::1]:53                      [::]:*         users:(("dnsmasq",pid=18295,fd=11))
LISTEN     0          128                             [::1]:6010                    [::]:*         users:(("sshd",pid=285982,fd=9))
LISTEN     0          128                             [::1]:6011                    [::]:*         users:(("sshd",pid=395705,fd=9))
root@yellow:~# systemctl stop docker
root@yellow:~# apt install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  mysql-client-8.0 mysql-common mysql-server-8.0
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  mysql-client-8.0 mysql-common mysql-server mysql-server-8.0
0 upgraded, 4 newly installed, 0 to remove and 114 not upgraded.
Need to get 0 B/1,288 kB of archives.
After this operation, 1,767 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 112964 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.8+1.0.5ubuntu2_all.deb ...
Unpacking mysql-common (5.8+1.0.5ubuntu2) ...
Selecting previously unselected package mysql-client-8.0.
Preparing to unpack .../mysql-client-8.0_8.0.21-0ubuntu0.20.04.4_amd64.deb ...
Unpacking mysql-client-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Setting up mysql-common (5.8+1.0.5ubuntu2) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-8.0.
(Reading database ... 112993 files and directories currently installed.)
Preparing to unpack .../mysql-server-8.0_8.0.21-0ubuntu0.20.04.4_amd64.deb ...
Unpacking mysql-server-8.0 (8.0.21-0ubuntu0.20.04.4) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_8.0.21-0ubuntu0.20.04.4_all.deb ...
Unpacking mysql-server (8.0.21-0ubuntu0.20.04.4) ...
Setting up mysql-client-8.0 (8.0.21-0ubuntu0.20.04.4) ...
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 404343
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (8.0.21-0ubuntu0.20.04.4) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3) ...
root@yellow:~# systemctl status mysql
● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
     Active: active (running) since Fri 2020-09-25 19:22:56 CST; 4min 33s ago
   Main PID: 404680 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 4657)
     Memory: 331.8M
     CGroup: /system.slice/mysql.service
             └─404680 /usr/sbin/mysqld

Sep 25 19:22:55 yellow systemd[1]: Starting MySQL Community Server...
Sep 25 19:22:56 yellow systemd[1]: Started MySQL Community Server.
root@yellow:~# ss -ntlp
State      Recv-Q     Send-Q                  Local Address:Port            Peer Address:Port     Process
LISTEN     0          4096                        127.0.0.1:45959                0.0.0.0:*         users:(("containerd",pid=2252,fd=6))
LISTEN     0          151                         127.0.0.1:3306                 0.0.0.0:*         users:(("mysqld",pid=404680,fd=33))
LISTEN     0          32                       10.236.187.1:53                   0.0.0.0:*         users:(("dnsmasq",pid=18295,fd=9))
LISTEN     0          4096                    127.0.0.53%lo:53                   0.0.0.0:*         users:(("systemd-resolve",pid=491,fd=13))
LISTEN     0          128                           0.0.0.0:22                   0.0.0.0:*         users:(("sshd",pid=672,fd=3))
LISTEN     0          128                         127.0.0.1:6010                 0.0.0.0:*         users:(("sshd",pid=285982,fd=10))
LISTEN     0          128                         127.0.0.1:6011                 0.0.0.0:*         users:(("sshd",pid=395705,fd=10))
LISTEN     0          70                                  *:33060                      *:*         users:(("mysqld",pid=404680,fd=31))
LISTEN     0          32             [fd42:2fe:1e1:9cb7::1]:53                      [::]:*         users:(("dnsmasq",pid=18295,fd=11))
LISTEN     0          128                             [::1]:6010                    [::]:*         users:(("sshd",pid=285982,fd=9))
LISTEN     0          128                             [::1]:6011                    [::]:*         users:(("sshd",pid=395705,fd=9))

相關文章