When I try to install mysql-server, an error comes like:
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
What does it mean. Any ideas?
All of the answers I've been able to find for this question have been of the form "purge your Mysql install and re-install it." But in my case, I already have a working/active Mysql install. For me, the reason why
dpkg --configure -a
fails is because Mysql is already installed. Why dpkg thinks that the postinstall script needs to be run for my already-installed-and-upgraded Mysql I may never know, but it does.After considerable time scouring for answers, I found a solution that should work if there are others who already have a working Mysql 5.7 and just want to get past this bogus postinstall script. You can edit the postinstall script directly as (on Ubuntu):
sudo vi /var/lib/dpkg/info/mysql-server-5.7.postinst
And then, on the second line, just add
exit 0
and then rundpkg
again and you should get something like:You definitely would not want to follow these instructions if your Mysql installation had not previously completed (there's a reason that the postinstall script insists on running). But for those who might end up with dpkg in a wonky state, as I have, the above can save you a lot of time purging and reinstalling an already-working version of Mysql.
This should help
And now reinstall mysql
dpkg
returning an error code 1 doesn't mean anything specific but it usually has to do with dependency issues. In your case, you tried to install two versions/instances of the same package i.e.mysql-server
andmysql-server-5.7
. So do the following to remove any redundant dependency issues and install a functioning mysql packagethis should fix the problem at hand. But in the future, have care about the package names you add after
sudo apt-get install
since the wrong list of package names - for example redundant entries in the list - results in failure to install either of the packages or worse - you might even find yourself wading through the hellish depths of #DEPENDENCY-HELLThe problem can be much simpler (in my case) I had a missconfigured value in my configuration file [my.cnf] which lead to the error. After cleaning up my.cnf mysql-server was restarted successfully