3

I have a damaged installation of MariaDB which I am trying to clean out and re-install.

If I do sudo apt-get upgrade I get the following remove:

You might want to run 'apt-get -f install' to correct these.
The following packages have unmet dependencies:
 mariadb-galera-server : Depends: mariadb-galera-server-5.5 (= 5.5.40+maria-1~wheezy) but it is not installed
E: Unmet dependencies. Try using -f.

If I run sudo apt-get install -f I get:

Preconfiguring packages ...
(Reading database ... 31610 files and directories currently installed.)
Unpacking mariadb-galera-server-5.5 (from .../mariadb-galera-server-5.5_5.5.40+maria-1~wheezy_amd64.deb) ...
Stopping MariaDB database server: mysqld failed!
invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 1
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!
dpkg: error processing /var/cache/apt/archives/mariadb-galera-server-5.5_5.5.40+maria-1~wheezy_amd64.deb (--unpack):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/mariadb-galera-server-5.5_5.5.40+maria-1~wheezy_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

If I try to uninstall using sudo apt-get --purge remove mariadb-galera-server-5.5 mariadb-galera-server mariadb-common I get:

The following packages have unmet dependencies:
 libmariadbclient18 : Depends: mariadb-common but it is not going to be installed
 mariadb-client-5.5 : Depends: mariadb-common but it is not going to be installed
 mariadb-client-core-5.5 : Depends: mariadb-common but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

I have run out of things to try, any help is much appreciated.

4 Answers 4

3

This seems to be a known issue as reported here. The most practical solution would be to first kill of all instances of mysqld that are running:

sudo killall mysqld

And then run this as suggested to get things running with MariaDB again:

sudo apt-get -f install

If somehow that doesn’t work, run dpkg --configure -a before the previous commands and try again.

14
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!

I had this problem yesterday when the mariadb 10.1 server package failed to update and install correctly. In the end deleting the following symbolic link may have fixed the problem.

root@box{~}:la /etc/systemd/system/mysql.service
lrwxrwxrwx 1 root root 35 Feb  9 22:55 /etc/systemd/system/mysql.service -> /lib/systemd/system/mariadb.service

The main error message I received was.

Failed at step NO_NEW_PRIVILEGES spawning /usr/sbin/mysqld: Invalid argument

I found the mariadb troubleshooting guide helpful but I couldn't find an answer to the error messages I was seeing anywhere. It wasn't until I tried to install Perconadb as an alternative drop in replacement that I found my way to that symbolic link.

https://mariadb.com/kb/en/mariadb/troubleshooting-installation-issues/

5
  • 1
    because mysql service wasn't running, I just removed /etc/systemd/system/mysql.service and installation passed. The file was probably left from previous installation..who knows.
    – Ivan Stana
    Mar 1, 2017 at 21:41
  • @IvanStana you just saved me after 2h of googling around trying to install mysql-server
    – mhz
    Apr 20, 2017 at 17:52
  • The same happened to us. After removing MySQL the /etc/systemd/system/mysql.service was still there, so the installation process detected it, tried to stop the service, failed (as there was no service to stop) and aborted the installation.
    – Sergi
    Aug 25, 2017 at 11:53
  • this worked for my on ubuntu 16.04.2 Sep 11, 2017 at 18:27
  • systemctl disable mysqld Mar 23, 2020 at 7:14
0

If none of the aformentioned workarounds did the trick try these two commands.

sudo rm /etc/systemd/system/mysqld.service
sudo rm /etc/systemd/system/mysql.service

Then run

sudo apt -f install
0

For me it started as I was installing akeneo with mariadb I got the error:

+---------+----------------------------------------------------------------------------------------------------------------------------+
| Check   | Errors                                                                                                                     
|
+---------+----------------------------------------------------------------------------------------------------------------------------+
| ERROR   | Install MySQL greater or equal to 5.7.0 and lower than 5.8.0 (installed version is 5.5.5-10.1.30-MariaDB-0ubuntu0.17.10.1) |
+---------+----------------------------------------------------------------------------------------------------------------------------+

For some reason Akeneo would not work with this setting, even though it seems like mariadb was based on mysql 5.7. So I needed to switch mariadb to mysql-server.

sudo apt-get install mysql-server

The install removed mariadb, but will reinstalling mysql there was this error:

invoke-rc.d: initscript mysql, action "stop" failed.
invoke-rc.d returned 5
There is a MySQL server running, but we failed in our attempts to stop it.
Stop it yourself and try again!

I could not find any running sql server with

sudo ps -aux | grep sql

Or anything else, so I tried to uninstall all mysql related packages. Whatever I would try next, be it purging uninstalling mysql-server or mariadb nothing would work even:

apt --fix-broken install

So I had to look for the packages with:

sudo dpkg --get-selections | grep mysql

Which gave me:

libdbd-mysql-perl                               install
libmysqlclient20:amd64                          install
mysql-client-5.7                                install
mysql-client-core-5.7                           install
mysql-common                                    install
mysql-server                                    install
mysql-server-core-5.7                           install
php-mysql                                       install
php7.1-mysql                                    install

and

sudo dpkg --get-selections | grep mariadb

which gave me :

mariadb-client-10.1                             deinstall
mariadb-common                                  install
mariadb-server-10.1                             deinstall

I then proceeded to remove all the packages I found with

sudo dpkg -P <packagename>

And FINALLY I could reinstall with

sudo apt-get install mysql-server

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .