Ubuntu20.04安装MySQL8.0时出现依赖错误解决办法

博文背景

在使用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))
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值