删除以前安装的 MariaDB 后尝试在 Ubuntu 17.10 上安装 MySQL。
为了清除所有内容,我运行了以下命令:
sudo apt-get remove --purge *mysql*
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get remove --purge *mariadb*
sudo apt-get autoremove
sudo apt-get autoclean
已验证 MySQL 和 MariaDB 均已被删除:
dpkg -l | grep mariadb
dpkg -l | grep mysql
现在当我尝试重新安装 MySQL
sudo apt update
sudo apt 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:
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 3 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 ... 281851 files and directories currently installed.)
Preparing to unpack .../0-mysql-common_1%3a10.3.8+maria~artful_all.deb ...
Unpacking mysql-common (1:10.3.8+maria~artful) ...
Selecting previously unselected package libaio1:amd64.
Preparing to unpack .../1-libaio1_0.3.110-4_amd64.deb ...
Unpacking libaio1:amd64 (0.3.110-4) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../2-mysql-client- core-5.7_5.7.22-0ubuntu0.17.10.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.22-0ubuntu0.17.10.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../3-mysql-client- 5.7_5.7.22-0ubuntu0.17.10.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.22-0ubuntu0.17.10.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../4-mysql-server- core-5.7_5.7.22-0ubuntu0.17.10.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.22-0ubuntu0.17.10.1) ...
Selecting previously unselected package libevent-core-2.1-6:amd64.
Preparing to unpack .../5-libevent-core-2.1-6_2.1.8-stable-4_amd64.deb ...
Unpacking libevent-core-2.1-6:amd64 (2.1.8-stable-4) ...
Setting up mysql-common (1:10.3.8+maria~artful) ...
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 282013 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.22-0ubuntu0.17.10.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.22-0ubuntu0.17.10.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.22-0ubuntu0.17.10.1_all.deb ...
Unpacking mysql-server (5.7.22-0ubuntu0.17.10.1) ...
Setting up libevent-core-2.1-6:amd64 (2.1.8-stable-4) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for libc-bin (2.26-0ubuntu2.1) ...
Setting up libaio1:amd64 (0.3.110-4) ...
Processing triggers for systemd (234-2ubuntu12.4) ...
Processing triggers for man-db (2.7.6.1-2) ...
Setting up mysql-client-core-5.7 (5.7.22-0ubuntu0.17.10.1) ...
Setting up mysql-server-core-5.7 (5.7.22-0ubuntu0.17.10.1) ...
Setting up mysql-client-5.7 (5.7.22-0ubuntu0.17.10.1) ...
Setting up mysql-server-5.7 (5.7.22-0ubuntu0.17.10.1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 143: /usr/share/mysql- common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script 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.
Processing triggers for libc-bin (2.26-0ubuntu2.1) ...
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
我尝试注释掉 /var/lib/dpkg/info/mysql-server-5.7.postinst 中的第 143 行,但没有帮助。
任何帮助都将不胜感激。考虑使用 docker 镜像作为解决方法。
答案1
因此我能够使用以下命令成功安装最新版本的 MySQL。
再次,让我们清除所有东西
sudo apt-get remove --purge *mysql*
sudo rm -rf /etc/mysql /var/lib/mysql
sudo apt-get remove --purge *mariadb*
sudo apt-get autoremove
sudo apt-get autoclean
再次确认 MySQL 和 MariaDB 均已删除
dpkg -l | grep mariadb
dpkg -l | grep mysql
按照此答案中概述的步骤修复任何 dpkg 锁问题:
https://askubuntu.com/a/291584/864498
现在获取并重新安装 MySQL
cd /tmp/ && wget https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.3-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server mysql-client