我尝试在 Ubuntu 上安装 MySQL,但出现以下错误。我尝试了本网站和互联网上的一些解决方案,但似乎都不起作用。
$ 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.24-0ubuntu0.18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 24 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-5.7 (5.7.24-0ubuntu0.18.04.1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 191: /usr/share/mysql-
common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned
error exit status 127
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error
from a previous failure.
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
编辑:我删除了 mysql 包并尝试按照评论中的指示再次安装它。
$ sudo apt-get remove --purge mysql*
$ sudo apt-get purge mysql*
$ sudo apt-get autoremove
$ sudo apt-get autoclean
$ sudo apt-get remove dbconfig-mysql
$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libaio1 libevent-core-2.1-6 mysql-client-5.7 mysql-client-core-5.7
mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
mailx tinyca
The following NEW packages will be installed:
libaio1 libevent-core-2.1-6 mysql-client-5.7 mysql-client-core-5.7
mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 8 newly installed, 0 to remove and 5 not upgraded.
Need to get 0 B/20.4 MB of archives.
After this operation, 160 MB 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 ... 173195 files and directories currently installed.)
Preparing to unpack .../0-mysql-common_10.2.19+maria~xenial_all.deb ...
Unpacking mysql-common (10.2.19+maria~xenial) ...
它尝试安装但最后出现了类似的错误。
Setting up mysql-client-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Setting up mysql-server-5.7 (5.7.24-0ubuntu0.18.04.1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 191: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (237-3ubuntu10.9) ...
Processing triggers for ureadahead (0.100.0-20) ...
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
由于从 ubuntu 18.04 升级到 Ubuntu 20.04 时出现问题,我遇到了同样的错误。我所做的是获取 MariaDB,同时确保在清除 MySQL 时,如果要求删除目录中的数据库,请单击“否”。它不会删除数据库,因此您将拥有旧数据库并且不会丢失数据。
我使用了这些命令:
sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
sudo apt-get install mariadb-server
答案2
这为我修复了这个问题(MySQL 8.0-Ubuntu 20.04)
sudo apt-get purge mysql\* libmysql\*
sudo apt autoremove
但该方案“mysql-客户端核心-8.0“不要卸载,所以...
sudo apt --fix-broken install
sudo apt-get --reinstall install mysql-client-core-8.0
sudo apt-get purge mysql\* libmysql\*
sudo apt autoremove
sudo apt update
sudo apt install mysql-server
不再有错误!