在服务器上安装 MySQL 失败

在服务器上安装 MySQL 失败

我正在尝试安装 MySQL(和 phpmyadmin)。首先我要使用以下命令安装 MySQL:

sudo apt-get install mysql-server

但它抛出了:

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

我搜索了很多次这个错误,但没有结果:-(。我试过了apt-get -f install,它抛出了:

Do you want to continue? [Y/n] y
Preconfiguring packages ...
(Reading database ... 60463 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.5_5.5.35+dfsg-1ubuntu1_amd64.deb ...
Aborting downgrade from (at least) 5.6 to 5.5.
If are sure you want to downgrade to 5.5, remove the file
/var/lib/mysql/debian-*.flag and try installing again.
dpkg: error processing archive /var/cache/apt/archives/mysql-server-5.5_5.5.35+dfsg-1ubuntu1_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.5_5.5.35+dfsg-1ubuntu1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

知道如何修复该问题吗?

答案1

你已经mysql 5.6在你的机器上安装了,试试这个命令来查看版本

mysql --version

要启动服务,请尝试以下命令:

sudo service mysql start

如果错误仍然存​​在,您可以使用purge现有包并安装一个新的包:

sudo apt-get purge mysql-server mysql-common 
sudo apt-get purge mysql-client
sudo apt-get autoremove mysql-server mysql-client mysql-common 
sudo apt-get autoclean mysql-server mysql-client mysql-common 

重新安装:

sudo apt-get install mysql-server mysql-common mysql-client

相关内容