我正在尝试在 ubuntu 16 上安装 apache 和 mysql 服务器

我正在尝试在 ubuntu 16 上安装 apache 和 mysql 服务器

请有人告诉我为什么我的终端显示:

root@prince-HP-ProBook-6470b:~# apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  galera-3 iproute libdbd-mysql-perl libdbi-perl libjemalloc1
  libmariadbclient18 libmysqlclient18 libreadline5 mariadb-common socat
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  mysql-server-5.7
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  mysql-client mysql-server mysql-server-5.7
0 upgraded, 3 newly installed, 0 to remove and 4 not upgraded.
Need to get 0 B/2,592 kB of archives.
After this operation, 48.6 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 189575 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.15-0ubuntu0.16.04.1_amd64.deb ...
Aborting downgrade from (at least) 10.1 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.15-0ubuntu0.16.04.1_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Selecting previously unselected package mysql-client.
Preparing to unpack .../mysql-client_5.7.15-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-client (5.7.15-0ubuntu0.16.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.15-0ubuntu0.16.04.1_all.deb ...
Unpacking mysql-server (5.7.15-0ubuntu0.16.04.1) ...
Errors were encountered while processing:
 /var/cache/apt/archives/mysql-server-5.7_5.7.15-0ubuntu0.16.04.1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@prince-HP-ProBook-6470b:~# systemctl start apache2
root@prince-HP-ProBook-6470b:~# apt-get purge apache2
Reading package lists... Done
Building dependency tree       
Reading state information... Done
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).

答案1

 sudo apt-get autoclean

删除 sources.list 文件并创建新的 sources.list...

sudo rm /etc/apt/sources.list 

然后输入

sudo software-properties-gtk 

在此处输入图片描述 这将打开 software-properties-gtk 并自动创建一个 newsources.list。

然后将服务器更改为美国或您选择的任何其他服务器。您必须从新对话框中启用存储库才能创建新的 sources.list。

勾选所有框然后单击“恢复”,再单击“关闭”。

需要恢复默认存储库

 sudo apt-get update && sudo apt-get dist-upgrade -y

(最好在安装之前备份此文件,以便在发生此类情况时进行恢复)

现在安装任何东西!

答案2

好吧,这个操作表明,您之前已经安装了 mariadb,现在正在安装 mysql 服务器,这似乎导致了这个问题。最好删除 mariadb、mysql-server 和 apache 并清理缓存,然后尝试重新安装 mysql-server 和 apache。

删除 mariadb。

sudo apt-get remove --purge mariadb-*

如果已安装,请删除 mysql-server 和 apache2。

sudo apt-get remove --purge mysql-server apache2

删除不需要的依赖项并清理。

 sudo apt-get autoremove
 sudo apt-get autoclean

现在继续逐一安装。
注意:不要同时安装 mariadb 和 mysql-server,因为 fromer 是后者的一个分支,并且两者的用途相同。

相关内容