4

I am trying to install MySQL on my Ubuntu but getting the following error. I tried some of the solutions available on this website and on the internet, but none of it seems to work.

$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
mysql-server is already the newest version (5.7.24-0ubuntu0.18.04.1).
0 upgraded, 0 newly installed, 0 to remove and 24 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up mysql-server-5.7 (5.7.24-0ubuntu0.18.04.1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 191: /usr/share/mysql- 
common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
 installed mysql-server-5.7 package post-installation script subprocess returned 
error exit status 127
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error 
from a previous failure.

Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)

EDIT: I removed the mysql package and tried to installed it again as instructed in the comment.

$ sudo apt-get remove --purge mysql*
$ sudo apt-get purge mysql*
$ sudo apt-get autoremove
$ sudo apt-get autoclean
$ sudo apt-get remove dbconfig-mysql
$ sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libaio1 libevent-core-2.1-6 mysql-client-5.7 mysql-client-core-5.7
  mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
  mailx tinyca
The following NEW packages will be installed:
  libaio1 libevent-core-2.1-6 mysql-client-5.7 mysql-client-core-5.7
  mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 8 newly installed, 0 to remove and 5 not upgraded.
Need to get 0 B/20.4 MB of archives.
After this operation, 160 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 173195 files and directories currently installed.)
Preparing to unpack .../0-mysql-common_10.2.19+maria~xenial_all.deb ...
Unpacking mysql-common (10.2.19+maria~xenial) ...

It tried installing but towards the end gave a similar error.

Setting up mysql-client-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Setting up mysql-server-5.7 (5.7.24-0ubuntu0.18.04.1) ...
/var/lib/dpkg/info/mysql-server-5.7.postinst: line 191: /usr/share/mysql-common/configure-symlinks: No such file or directory
dpkg: error processing package mysql-server-5.7 (--configure):
 installed mysql-server-5.7 package post-installation script subprocess returned error exit status 127
dpkg: dependency problems prevent configuration of mysql-server:
 mysql-server depends on mysql-server-5.7; however:
  Package mysql-server-5.7 is not configured yet.

dpkg: error processing package mysql-server (--configure):
 dependency problems - leaving unconfigured
Processing triggers for libc-bin (2.27-3ubuntu1) ...
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Processing triggers for systemd (237-3ubuntu10.9) ...
Processing triggers for ureadahead (0.100.0-20) ...
Errors were encountered while processing:
 mysql-server-5.7
 mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
8
  • try sudo service mysql stop and sudo service mysqld stop then sudo apt-get install mysql-server – mature Dec 6 '18 at 13:09
  • Tried. sudo service mysqld stop gave an error - Failed to stop mysqld.service: Unit mysqld.service not loaded. The installation gives the same error – Bhuvan Chandra Dec 6 '18 at 13:13
  • 2
    Try sudo dpkg --configure -a. – Jos Dec 6 '18 at 13:18
  • In your log you already have a mysql-server installed in your system.. If you want fully reinstall it (without data save) try sudo apt-get remove --purge mysql*, sudo apt-get purge mysql*, sudo apt-get autoremove, sudo apt-get autoclean, sudo apt-get remove dbconfig-mysqlthen sudo apt-get install mysql-server – mature Dec 6 '18 at 13:19
  • @mature: Yes, mysql got removed, but it gave the same error in the last command while I tried to install it. Rest of the commands worked pretty fine, without any error. – Bhuvan Chandra Dec 6 '18 at 13:32
0

I faced same error due to problem in my upgrade from ubuntu 18.04 to Ubuntu 20.04. What I did is get MariaDB instead also make sure when you do purge MySQL and if asked to remove databases in the directory, click on "No". It would not delete the databases so you will have your old databases and no data loss.

I used these commands:

sudo apt-get purge mysql*
sudo apt-get autoremove
sudo apt-get autoclean
sudo apt-get dist-upgrade
sudo apt-get install mariadb-server
1
0

This fixed it for me (MySQL 8.0 - Ubuntu 20.04)

sudo apt-get purge mysql\* libmysql\*
sudo apt autoremove

But the package "mysql-client-core-8.0" don't uninstall, so...

sudo apt --fix-broken install
sudo apt-get --reinstall install mysql-client-core-8.0
sudo apt-get purge mysql\* libmysql\*
sudo apt autoremove
sudo apt update
sudo apt install mysql-server

No more errors!

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.