无法在 Ubuntu 16.04 上安装 MySQL
Posted
技术标签:
【中文标题】无法在 Ubuntu 16.04 上安装 MySQL【英文标题】:Can't install MySQL on Ubuntu 16.04 【发布时间】:2017-12-30 23:05:04 【问题描述】:我在安装 mysql-server
之前安装了 mariadb-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
?
【问题讨论】:
或许在askubuntu.com 发帖会更好 如果您在 [askubuntu.com] 中提出这些问题可能会更好ps aux | grep mysql
并杀死进程
【参考方案1】:
我通过删除apt-get purge mysql*
没有删除的所有 MySQL 文件来让它工作:
sudo rm -rf /var/lib/mysql/mysql
【讨论】:
这对我没有帮助 也许很明显,但我想应该提到的是,删除这个目录也很可能会删除你所有的数据库。以上是关于无法在 Ubuntu 16.04 上安装 MySQL的主要内容,如果未能解决你的问题,请参考以下文章
无法在 Docker 中的 ubuntu 16.04 上安装 openssh-server
无法在 Ubuntu 16.04 服务器上安装 dotnet-sdk2.1
如何在 Ubuntu 16.04 上安装 mysql2 [错误:安装 mysql2 时出错:错误:无法构建 gem 本机扩展。] [重复]