ubuntu16.04安装Mysql-server报错

Error in installing Mysql-server in ubuntu16.04

这是我遇到的错误

Setting up mysql-server-5.7 (5.7.12-0ubuntu1.1) ...
Job for mysql.service failed because the control process exited with error code. See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
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
Processing triggers for man-db (2.7.5-1) ...
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)

按照上述代码第 2 行中的说明进行操作后,我得到

$ systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en
   Active: activating (start-post) (Result: exit-code) since Tue 2016-07-05 18:2
  Process: 7822 ExecStart=/usr/sbin/mysqld (code=exited, status=1/FAILURE)
  Process: 7819 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exit
 Main PID: 7822 (code=exited, status=1/FAILURE);         : 7823 (mysql-systemd-s
   CGroup: /system.slice/mysql.service
           └─control
             ├─7823 /bin/bash /usr/share/mysql/mysql-systemd-start post
             └─7874 sleep 1


$ journalctl -xe
-- Subject: Unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has failed.
-- 
-- The result is failed.
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: mysql.service: Unit entere
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: mysql.service: Failed with
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: mysql.service: Service hol
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: Stopped MySQL Community Se
-- Subject: Unit mysql.service has finished shutting down
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has finished shutting down.
Jul 05 18:29:59 rahul-HP-2000-Notebook-PC systemd[1]: Starting MySQL Community S
-- Subject: Unit mysql.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit mysql.service has begun starting up.

我试过多次重新安装,但总是显示相同的错误。这个错误的原因是什么?

使用清除删除所有 mysql 包:

$ sudo apt-get remove --purge mysql*

$ sudo apt-get autoremove --purge

如果目录/etc/mysql仍然存在,执行上述命令后,则强制删除:

$ sudo rm -rf /etc/mysql

现在,首先,安装软件包 mysql-client:

$ sudo apt-get install mysql-client

最后,在成功安装 mysql-client 后安装包 mysql-server:

$ sudo apt-get install mysql-server

上述命令是我发现修复 mysql-server 上的安装错误的唯一方法。

我已经尝试了以下链接中描述的所有解决方案,但其中 none 有效!

https://askubuntu.com/questions/766038/error-installing-mysql-on-ubuntu-16-04

https://askubuntu.com/questions/760724/16-04-upgrade-broke-mysql-server

https://ubuntuforums.org/showthread.php?t=2325143

https://bugs.launchpad.net/ubuntu/+source/mysql-5.7/+bug/1573279 https://askubuntu.com/questions/760724/16-04-upgrade-broke-mysql-server