12

I'm having a problem with mysql installation which I can't resolve alone. First I tried to remove and purge old files with this command

sudo apt-get remove --purge mysql

Tried also

sudo apt-get remove --purge mysql*

And

sudo apt-get remove --purge mariadb*

All 3 commands return same output ...

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

So i run what is suggested me apt-get -f install and I've got

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

Same output I get when I run apt upgrade -f. This is the output of 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'.

Another thing I've tried was to remove mysql-server and then install it again still same error.

Can anyone help with this issue.. I'm out of ideas how can I fix it.

Update output of 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: output of 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).
1
  • try sudo apt --fix-broken install to fix broken packages first, if that does not work then search using grep and remove existing packages. – Hemant Kumar Mar 26 at 10:07
29

We execute the following commands to solve the above problem:

  1. Get the list of MySQL packages installed on the system by executing the command sudo dpkg -l | grep mysql
  2. Remove the the packages shown above by executing the command sudo apt-get --purge autoremove <packages from the step 1>
  3. Delete /var/lib/mysql
  4. Try to install mysql again. It should solve your problem.
9
  • Thnak's for the answer. I've tried but on second step where purge and autoremove them whatever package I tried to purge I've got same error: 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). – S.I. Nov 23 '16 at 6:56
  • Can please provide the output of the command lsb_release -a – Bidyut Nov 23 '16 at 7:22
  • I've updated my question with the output. – S.I. Nov 23 '16 at 7:27
  • execute sudo apt-get update then execute sudo apt install mysql-server mysql-client – Bidyut Nov 23 '16 at 7:31
  • Updated my question with output of sudo apt install mysql-server mysql-client – S.I. Nov 23 '16 at 7:34
1

I have no idea why, I tried around with these commands for like an hour untill I just made

export TERM=xterm

and then it just worked with apt install.

EDIT: Actually now I know why. It might be that during the installation it's trying to bring up the visual interface asking "install the package maintainter's version" and similar, and the default TERM on some Ubuntu servers is not able to serve that, so the installation throws an error. Xterm use solves that problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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