无法在ubuntu 16上安装mysql-server / client


12

我的mysql安装有问题,我无法单独解决。首先,我尝试使用此命令删除和清除旧文件

sudo apt-get remove --purge mysql

也试过了

sudo apt-get remove --purge mysql*

sudo apt-get remove --purge mariadb*

所有3条命令返回相同的输出...

You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
dbconfig-mysql : Depends: mysql-client but it is not going to be installed or
                       mariadb-client but it is not going to be installed or
                       virtual-mysql-client
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

所以我运行了建议我的东西apt-get -f install,我已经

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following additional packages will be installed:
  mysql-server-5.7
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  mysql-server-5.7
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/2,597 kB of archives.
After this operation, 48.3 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 300885 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.16-0ubuntu0.16.04.1_amd64.deb ...
Aborting downgrade from (at least) 10.0 to 5.7.
If are sure you want to downgrade to 5.7, remove the file
/var/lib/mysql/debian-*.flag and try installing again.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.7_5.7.16-0ubuntu0.16.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.7_5.7.16-0ubuntu0.16.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

运行时得到的输出相同apt upgrade -f。这是输出systemctl status mysql.service -l

$ systemctl status mysql.service -l
    ● mysql.service
       Loaded: not-found (Reason: No such file or directory)
       Active: failed (Result: exit-code) since Wed 2016-11-23 07:32:55 EET; 58min ago

    Nov 23 07:32:24 stan systemd[1]: Starting LSB: Start and stop the mysql database server daemon...
    Nov 23 07:32:24 stan mysql[7818]:  * Starting MariaDB database server mysqld
    Nov 23 07:32:55 stan mysql[7818]:    ...fail!
    Nov 23 07:32:55 stan systemd[1]: mysql.service: Control process exited, code=exited status=1
    Nov 23 07:32:55 stan systemd[1]: Failed to start LSB: Start and stop the mysql database server daemon.
    Nov 23 07:32:55 stan systemd[1]: mysql.service: Unit entered failed state.
    Nov 23 07:32:55 stan systemd[1]: mysql.service: Failed with result 'exit-code'.

我尝试过的另一件事是删除mysql-server然后再次安装它,仍然是同样的错误。

任何人都可以帮助解决这个问题。.我不知道如何解决它。

更新输出 lsb_release -a

$ lsb_release -a
  No LSB modules are available.
  Distributor ID:   Ubuntu
  Description:  Ubuntu 16.04.1 LTS
  Release:  16.04
  Codename: xenial 

Update2:输出 sudo apt install mysql-server mysql-client

$ sudo apt install mysql-server mysql-client
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  mysql-client is already the newest version (5.7.16-0ubuntu0.16.04.1).
  mysql-server is already the newest version (5.7.16-0ubuntu0.16.04.1).
  You might want to run 'apt-get -f install' to correct these:
  The following packages have unmet dependencies:
  mysql-server : Depends: mysql-server-5.7 but it is not going to be installed
  E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Answers:


28

我们执行以下命令来解决上述问题:

  1. 通过执行以下命令获取系统上安装的MySQL软件包的列表 sudo dpkg -l | grep mysql
  2. 通过执行以下命令删除上面显示的软件包 sudo apt-get --purge autoremove <packages from the step 1>
  3. 删除 /var/lib/mysql
  4. 尝试再次安装mysql。它应该可以解决您的问题。

Thnak的答案。我已经尝试过,但是在第二步中,我要清除的任何程序包都进行清除和自动删除,但我遇到了同样的错误:You might want to run 'apt-get -f install' to correct these: The following packages have unmet dependencies: mysql-server : Depends: mysql-server-5.7 but it is not going to be installed E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).
SI

能否提供命令的输出lsb_release -a
Bidyut '16

我已经用输出更新了我的问题。
SI

执行sudo apt-get update然后执行sudo apt install mysql-server mysql-client
Bidyut '16

更新了我的问题,输出为sudo apt install mysql-server mysql-client
SI

1

我不知道为什么,我花了一个小时尝试这些命令,直到我刚刚做了

export TERM=xterm

然后就可以使用apt install了。

编辑:实际上,现在我知道为什么了。可能是在安装过程中,它试图显示要求“安装软件包维护者的版本”及类似内容的可视界面,而某些Ubuntu服务器上的默认TERM无法提供该功能,因此安装会引发错误。Xterm的使用解决了这个问题。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.