Question: How should I solve below situation? It seems like my system thinks I have MySQL 10 (?) installed.

My scenario: Upgraded to php7.1, lost support between PHP and MySQL. Had a brain bug and tried to upgrade MySQL (through new installation), stuck with the following:

  1. A WordPress site Im running says this: Your PHP installation seems to miss the MySQL extension that WordPress requires.
  2. Trying to install the extension: apt-get install php7.1-mysql
  3. Getting the following answer:

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).

  1. Running: apt-get -f install
  2. Getting the following answer:

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.

  1. Running Y
  2. Getting the following answer:

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, for Linux (x86_64) using EditLine wrapper

  • mysql / -find mysql, gives me this:

/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

  • Please edit your question to elaborate on exactly what you may have done to cause the problem. Helping you undo the damage is much easier and safer if we understand what you originally did. – user535733 Feb 27 '18 at 16:38

Seems like you have several problems here, the first one is not important although you have unnecessary packages, I'd rather recommend to run apt-get autoremove

Then, follow this steps:

  1. First at all I don't know why you have a MySQL 10 (Does it exists?), however it gives you a recommendation remove the file /var/lib/mysql/debian-*.flag so you can run rm -rf /var/lib/mysql/debian-*.flag and try to reinstall MySQL with apt-get install mysql-server-5.7

If this work, I'd rather recommend to run apt-get -f install...

If step 1 doesn't work run this. BE CAREFUL

  1. I'd rather recommend to uninstall all MySQL packages, but BE CAREFUL, first of all you must backup your database directory (usually it is located in /var/lib/mysql), also backup /etc/mysql/my.cnf file, check that MySQL server is not running and move all content of your database directory to a new directory... The run dpkg -l | grep -i mysql and uninstall all MySQL server packages with apt-get remove --purge YOUR_MYSQL_PACKAGES.

  2. Reinstall MySQL running apt-get install mysql-server-5.7, stop MySQL instance with service mysql stop and replace /var/lib/mysql directory with your previouslly taken backup, besides replace /etc/mysql/my.cnf with your previous configuration saved in step2... Then start MySQL service mysql start and check MySQL server starts correctly.

Please be careful, if you don't know what are steps 2 and 3 for don't run them, you can lose all your database.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.