首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当apt-get和dpkg没有帮助时,如何强制删除带有未满足依赖项的MySQL和MariaDB?

问当apt-get和dpkg没有帮助时,如何强制删除带有未满足依赖项的MySQL和MariaDB?
EN

Server Fault用户
提问于 2018-06-04 21:00:11
回答 1查看 6.9K关注 0票数 0

我在我的Ubuntu16.04LTS上安装了mysql-server,它运行得很好.

接下来,我安装了mariadb-server和mariadb-client。有一些与MySQL的连接,所以我决定强制卸载所有的MariaDB组件。在那之后,我对MySQL有了问题。所以我决定强行重新安装MySQL..。

我无法卸载mysql-server,因为卸载MariaDB后存在未满足的依赖关系.

因此,我尝试了所有可能的组合与apt-get和dpkg强行移除MySQL和MariaDB的遗骸.最后,不幸的是,我还手动删除了目录树中的所有文件,其中包含了来自MySQL或MariaDB的任何文件.

代码语言:javascript
复制
$ sudo dpkg --audit
The following packages have been unpacked but not yet configured.
They must be configured using dpkg --configure or the configure
menu option in dselect for them to work:
 mysql-server         MySQL Server meta package depending on latest version

The following packages are missing the list control file in the
database, they need to be reinstalled:
 mariadb-client       MariaDB database client (metapackage depending on the lat
 mariadb-server-10.0  MariaDB database server binaries
 mariadb-server-core-10.0 MariaDB database core server files

The following packages are missing the md5sums control file in the
database, they need to be reinstalled:
 mariadb-client       MariaDB database client (metapackage depending on the lat
 mariadb-server-10.0  MariaDB database server binaries
 mariadb-server-core-10.0 MariaDB database core server files

但是我仍然不能重新安装MySQL,因为与MariaDB相关的依赖项丢失了,反之亦然.

代码语言:javascript
复制
$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-server is already the newest version (5.7.22-1ubuntu16.04).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 mariadb-client : Depends: mariadb-client-10.0 (>= 10.0.34-0ubuntu0.16.04.1) but it is not going to be installed
 mariadb-server-10.0 : PreDepends: mariadb-common (>= 10.0.34-0ubuntu0.16.04.1) but it is not going to be installed
                       Depends: mariadb-client-10.0 (>= 10.0.34-0ubuntu0.16.04.1) but it is not going to be installed
                       Breaks: mysql-server
 mariadb-server-core-10.0 : Depends: mariadb-common (>= 10.0.34-0ubuntu0.16.04.1) but it is not going to be installed
 mysql-server : Depends: mysql-community-server (= 5.7.22-1ubuntu16.04) but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).


$ sudo dpkg --configure mysql-server
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-community-server (= 5.7.22-1ubuntu16.04); however:
  Package mysql-community-server is not installed.
 mariadb-server-10.0 (10.0.34-0ubuntu0.16.04.1) breaks mysql-server and is installed.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 mysql-server

还有另一份清单:

代码语言:javascript
复制
$ sudo dpkg --list | grep -i mysql
ii  dbconfig-mysql                             2.0.4ubuntu1                                             all          dbconfig-common MySQL/MariaDB support
ii  libdbd-mysql-perl                          4.033-1ubuntu0.1                                         amd64        Perl5 database interface to the MySQL database
ii  libmysqlclient20:amd64                     5.7.22-0ubuntu0.16.04.1                                  amd64        MySQL database client library
ii  mysql-apt-config                           0.8.9-1                                                  all          Auto configuration for MySQL APT Repo.
ii  mysql-common                               5.7.22-0ubuntu0.16.04.1                                  all          MySQL database common files, e.g. /etc/mysql/my.cnf
iU  mysql-server                               5.7.22-1ubuntu16.04                                      amd64        MySQL Server meta package depending on latest version
rc  mysql-server-5.7                           5.7.22-0ubuntu0.16.04.1                                  amd64        MySQL database server binaries and system database setup
ii  php-mysql                                  1:7.2+60+ubuntu16.04.1+deb.sury.org+1                    all          MySQL module for PHP [default]
ii  php5.6-mysql                               5.6.35-1+ubuntu16.04.1+deb.sury.org+1                    amd64        MySQL module for PHP
ii  php7.2-mysql                               7.2.5-1+ubuntu16.04.1+deb.sury.org+1                     amd64        MySQL module for PHP
ii  phpmyadmin                                 4:4.5.4.1-2ubuntu2                                       all          MySQL web administration tool
ii  python-pymysql                             0.7.2-1ubuntu1                                           all          Pure-Python MySQL driver - Python 2.x


$ sudo dpkg --list | grep -i mariadb
ii  dbconfig-mysql                             2.0.4ubuntu1                                             all          dbconfig-common MySQL/MariaDB support
ii  mariadb-client                             10.0.34-0ubuntu0.16.04.1                                 all          MariaDB database client (metapackage depending on the latest version)
ii  mariadb-server-10.0                        10.0.34-0ubuntu0.16.04.1                                 amd64        MariaDB database server binaries
ii  mariadb-server-core-10.0                   10.0.34-0ubuntu0.16.04.1                                 amd64        MariaDB database core server files


$ sudo dpkg -i | grep mysql
dpkg: error: --install needs at least one package archive file argument


$ sudo dpkg -i | grep mariadb
dpkg: error: --install needs at least one package archive file argument

实际上,我需要在我的系统上安装MySQL,但是我不能重新安装Ubuntu。

我知道我自己制造了很多问题,但也许比我聪明的人能给我一些有用的建议。

我相信解决这个问题,可以帮助很多处于类似情况的人,其他服务也可以这样做。

EN

回答 1

Server Fault用户

回答已采纳

发布于 2018-06-05 09:08:41

上帝存在!

这一问题通过以下方式得到解决:

代码语言:javascript
复制
sudo apt-get -f install

没有任何其他参数

稍后,通过以下方式显示所有软件包:

代码语言:javascript
复制
sudo dpkg -l | grep mariadb
sudo dpkg -l | grep mysql

并按照正确的顺序删除有问题的包:

代码语言:javascript
复制
sudo apt-get --purge autoremove package_name

在完全删除所有有问题的软件包后,我可以重新安装MySQL,没有任何问题.

谢谢你@MarkWagner的帮助。

票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/915158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档