I see this is expired but I am running into this scenario again and the
steps to reproduce and fix this seem to be simple so I'm posting it here
because backlinks lead me here. This can occur in many Ubuntu versions
and it's essentially user error.

REPRODUCE:
The basic sequence and user reasoning appears to be:
1. User installs mysql-server

2. User decides to switch to mariadb, so he removes mysql packages but
he doesn't purge the data directory

3. Then after installing mariadb, the service fails to start because the
data directory is initialized by mysql. The person then decides to
remove the mysql data manually.

4. So the user uninstalls all mariadb packages and then manually deletes
the /etc/mysql and /var/lib/mysql directories.

5. But mysql-common is still lingering because it was installed as a
dependency of mariadb-common. So the manual deletion of /etc/mysql left
mysql-common in a broken state.

6. Now any attempts to install mariadb-server (or merely mariadb-common) will 
cause the installation to fail with this error:
update-alternatives: error: alternative path /etc/mysql/mariadb.cnf doesn't 
exist

A command sequence to reproduce this error is:
$ sudo apt -y purge 'mysql-*' 'mariadb-*' && sudo apt -y install mysql-server 
&& sudo apt -y remove 'mysql-*' && sudo apt -y install mariadb-server && sudo 
apt -y remove 'mariadb-*' && sudo rm -rf /etc/mysql /var/lib/mysql && sudo apt 
-y install mariadb-common

CONCLUSION AND FIX:
To avoid the user error use the "apt purge" when removing mysql instead of "apt 
remove" with manually deletion of mysql configuration/data, because this leaves 
mysql-common broken.

If you've run into this problem, a simple fix is:
$ sudo apt -y purge mysql-common && sudo apt -y install mariadb-server

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1676284

Title:
  package mariadb-common 10.0.29-0ubuntu0.16.04.1 failed to
  install/upgrade: subprocess installed post-installation script
  returned error exit status 2

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/mariadb-10.0/+bug/1676284/+subscriptions

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to