我mariadb-server
在安装之前就安装了mysql-server
(我不应该这样做),所以我mariadb*
从存储库中清除并删除了它。但是,我无法安装mysql-server
。
之后sudo apt-get install mysql-server
,我得到:
Setting up mysql-server-5.7 (5.7.19-0ubuntu0.16.04.1) ...
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ] 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)
invoke-rc.d: could not determine current runlevel
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ] invoke-rc.d: could not determine current runlevel
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up libhtml-tagset-perl (3.20-2) ...
Setting up liburi-perl (1.71-1) ...
Setting up libhtml-parser-perl (3.72-1) ...
Setting up libcgi-pm-perl (4.26-1) ...
Setting up libfcgi-perl (0.77-1build1) ...
Setting up libcgi-fast-perl (1:2.10-1) ...
Setting up libencode-locale-perl (1.05-1) ...
Setting up libhtml-template-perl (2.95-2) ...
Setting up libtimedate-perl (2.3000-2) ...
Setting up libhttp-date-perl (6.02-1) ...
Setting up libio-html-perl (1.001-1) ...
Setting up liblwp-mediatypes-perl (6.02-1) ...
Setting up libhttp-message-perl (6.11-1) ...
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.23-0ubuntu9) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (229-4ubuntu19) ...
Processing triggers for ureadahead (0.100.0-19) ...
Errors were encountered while processing:
mysql-server-5.7
E: Sub-process /usr/bin/dpkg returned an error code (1)
运行后sudo apt-get install -f
,我得到:
Setting up mysql-server-5.7 (5.7.19-0ubuntu0.16.04.1) ...
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ] Renaming removed key_buffer and myisam-recover options (if present)
invoke-rc.d: could not determine current runlevel
invoke-rc.d: could not determine current runlevel
* Stopping MySQL database server mysqld [ OK ] invoke-rc.d: could not determine current runlevel
mysql_upgrade: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) while connecting to the MySQL server
Upgrade process encountered error and will not continue.
mysql_upgrade failed with exit status 11
dpkg: error processing package mysql-server-5.7 (--configure):
subprocess installed post-installation script returned error exit status 1
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-server
?
答案1
看来 mariadb 并未被彻底删除/清除。
sudo apt-get purge mariadb*
sudo apt-get purge mysql*
sudo apt-get autoremove
删除 /etc/mysql 目录中的所有内容
rm -rf /etc/mysql/
现在安装 mysql-server
apt-get install mysql-server
如果上述步骤仍然显示任何错误,请尝试重新配置 dpkg
dpkg --configure -a