Ubuntu – Mysql Installation Problems with 18.04

18.04aptMySQLserversoftware installation

I installed a fresh copy of 18.04 am installing all the packages that are required. When installing mysql-server and mysql-client I receive the following error

dpkg: error processing package mysql-server-5.7 (--configure):
 installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
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.
                                                                                                          Processing triggers for libc-bin (2.27-3ubuntu1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Processing triggers for systemd (237-3ubuntu10) ...
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have tried the purge, autoremove, autoclean, dist-upgrade routine but it does not work for me.

How do I fix this problem, please help

Best Answer

I solved this problem by going to Oracles mysql documentation on MySQL APT Repository which was a huge help, following all the instructions on the page allowed me to install mysql successfully.

What I did:

  1. Download the mysql-apt-conf tool from http://dev.mysql.com/downloads/repo/apt/
  2. Install the package using sudo dpkg -i /PATH/version-specific-package-name.deb
  3. When installing select MySQL Server & Cluster to whatever you want by pressing enter and selecting one of mysql-5.7 or mysql-8.0 then go to Ok and press enter
  4. Then sudo apt-get update(this step is required only for Ubuntu 17.10 or below)
  5. Run sudo apt install mysql-server
  6. After the main packages are installed run mysql_secure_installation, this will configure the password and other security stuff for mysql


If anyone ran or had to run mysql_secure_installation withsudo, please note that you might not be able to login into mysql unless you use sudo. When this happens login to mysql console created a new user for mysql then flush all privileges. Check this question right here Connect to mysql server without sudo