When trying to install MariaDB 10.1 in an Ubuntu 16.04 Server with previous MySQL installed, even purging MySQL with sudo apt-get purge mysql*, I get this error message and the install process fail.

1 Answer 1


To ensure that everything is clean, you not only need to purge MySQL (and MariaDB) with:

sudo apt-get purge mysql* mariadb*

But you also need to remove old MySQL config folders, with:

sudo rm -rf /etc/mysql
sudo rm -rf /var/log/mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /var/lib/mysql-files
sudo rm -rf /var/lib/mysql-keyring

After these steps and correctly adding the MariaDB repositories, you can finally:

sudo apt update
sudo apt install mariadb-server
  • One liner to remove config folders: sudo rm -rf /etc/mysql && sudo rm -rf /var/log/mysql && sudo rm -rf /var/lib/mysql && sudo rm -rf /var/lib/mysql-files && sudo rm -rf /var/lib/mysql-keyring Oct 18, 2018 at 11:00

You must log in to answer this question.

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