问题:我应该如何解决以下情况?我的系统似乎认为我安装了 MySQL 10 (?)。
我的情况:升级到 php7.1,PHP 和 MySQL 之间失去支持。脑子里有个 bug,尝试升级 MySQL(通过全新安装),结果出现以下问题:
- 我正在运行的 WordPress 网站显示这样的信息:您的 PHP 安装似乎缺少 WordPress 所需的 MySQL 扩展。
- 尝试安装扩展:
apt-get install php7.1-mysql
- 得到以下答案:
Reading package lists... Done Building dependency tree Reading state information... Done php7.1-mysql is already the newest version (7.1.14-1+ubuntu16.04.1+deb.sury.org+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).
- 跑步:
apt-get -f install
- 得到以下答案:
Reading package lists... Done Building dependency tree Reading state information... Done Correcting dependencies... Done The following packages were automatically installed and are no longer required: fonts-liberation gconf-service gconf-service-backend gconf2-common letsencrypt libcommon-sense-perl libdbd-mysql-perl libdbi-perl libexpat1-dev libgconf-2-4 libjson-xs-perl libllvm3.8 liblua5.1-0 libpython-all-dev libpython-dev libpython2.7 libpython2.7-dev libreadline5 libtypes-serialiser-perl mariadb-common python-acme python-asn1crypto python-augeas python-certbot python-certbot-apache python-certifi python-cffi-backend python-chardet python-configargparse python-configobj python-configparser python-cryptography python-dialog python-dnspython python-enum34 python-funcsigs python-future python-idna python-ipaddress python-mock python-ndg-httpsclient python-openssl python-parsedatetime python-pbr python-pip-whl python-psutil python-pyasn1 python-pyicu python-requests python-rfc3339 python-six python-tz python-urllib3 python-zope.component python-zope.event python-zope.hookable python-zope.interface sensible-mda
Use 'apt autoremove' to remove them. **The following additional packages will be installed: mysql-server-5.7** Suggested packages: tinyca **The following NEW packages will be installed: mysql-server-5.7** 0 upgraded, 1 newly installed, 0 to remove and 26 not upgraded. 21 not fully installed or removed. Need to get 0 B/2,724 kB of archives. After this operation, 48.4 MB of additional disk space will be used.
- 跑步
Y
- 得到以下答案:
Preconfiguring packages ... (Reading database ... 76184 files and directories currently installed.) Preparing to unpack .../mysql-server-5.7_5.7.21-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.21-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.21-0ubuntu0.16.04.1_amd64.deb E: Sub-process /usr/bin/dpkg returned an error code (1)
mysql Ver 14.14 Distrib 5.7.21,适用于 Linux (x86_64),使用 EditLine 包装器
mysql / -find mysql,给我这个:
/etc/init.d/mysql /etc/default/mysql /etc/mysql /usr/bin/mysql /usr/share/php7.1-mysql/mysql /usr/share/php7.0-mysql/mysql /usr/share/dbconfig-common/internal/mysql /usr/share/dbconfig-common/data/phpmyadmin/install/mysql /usr/share/dbconfig-common/data/phpmyadmin/upgrade/mysql /usr/share/mysql /usr/include/mysql /usr/include/mysql/mysql /usr/lib/x86_64-linux-gnu/perl5/5.22/DBD/mysql /usr/lib/x86_64-linux-gnu/perl5/5.22/auto/DBD/mysql /var/log/mysql /var/lib/mysql /var/lib/mysql/mysql
答案1
好像你这里有几个问题,第一个问题并不重要,虽然你有不必要的包,但我宁愿建议运行apt-get autoremove
然后,按照以下步骤操作:
- 首先,我不知道你为什么有 MySQL 10(它存在吗?),但它给你一个建议
remove the file /var/lib/mysql/debian-*.flag
因此你可以运行rm -rf /var/lib/mysql/debian-*.flag
并尝试重新安装 MySQLapt-get install mysql-server-5.7
如果这有效,我宁愿建议运行apt-get -f install
...
如果步骤 1 不起作用,请运行此操作。小心
我宁愿建议卸载所有 MySQL 软件包,但要小心,首先必须备份数据库目录(通常位于
/var/lib/mysql
),还要备份/etc/mysql/my.cnf
文件,检查 MySQL 服务器是否未运行,并将数据库目录的所有内容移动到新目录...运行dpkg -l | grep -i mysql
并卸载所有 MySQL 服务器软件包apt-get remove --purge YOUR_MYSQL_PACKAGES
。重新安装 MySQL 并运行
apt-get install mysql-server-5.7
,停止 MySQL 实例并用您之前备份的目录service mysql stop
替换,此外还用您在步骤 2 中保存的先前配置替换...然后启动 MySQL并检查 MySQL 服务器是否正确启动。/var/lib/mysql
/etc/mysql/my.cnf
service mysql start
请小心,如果您不知道第 2 步和第 3 步是什么,请不要运行它们,否则您可能会丢失所有数据库。