I want to clearly remove mariadb on ubuntu 18.04, and reinstall it again.

But I have problems when trying it.

To remove mariadb clearly, I run this command as root

apt-get purge mariadb-server mariadb-client
apt-get autoremove

This is the log from /var/log/apt:

Start-Date: 2020-03-07  08:17:01
Commandline: apt install mariadb-server mariadb-client
Requested-By: xdnroot (1000)
Install: mariadb-server:amd64 (1:10.4.12+maria~bionic), mariadb-client:amd64 (1:10.4.12+maria~bionic)
End-Date: 2020-03-07  08:17:02

Start-Date: 2020-03-07  12:06:11
Commandline: apt-get purge mariadb-server mariadb-client
Purge: mariadb-server:amd64 (1:10.4.12+maria~bionic), mariadb-client:amd64 (1:10.4.12+maria~bionic)
End-Date: 2020-03-07  12:06:12

Then I deleted some binary files and directories that begining by "mysql" and "mariadb": /etc/mysql /var/lib/mysql and /var/lib/mariadb /usr/bin/mysql* and /usr/bin/mariadb* /usr/lib/mysql* and /usr/lib/mariadb*

First problem: When I reinstall mariadb, there is a log: "Reading database ... 283314 files and directories currently installed."

Second problem: After I reinstall mariadb-server and mariadb-client, I did not get the binary and library files and directories that I deteleted it before. Even /etc/mysql, I did not get it.

So, the question is "How to get mysql binary adn library files?"

  • Show us the complete output of your purge and autoremove. Your apt log with this information is in /var/log/apt.
    – user535733
    Mar 7, 2020 at 1:52
  • @user535733 sure, I have updated the question
    – xdnroot
    Mar 7, 2020 at 5:08
  • why not use the locate program? sudo updatedb; sudo locate mariadb mysql
    – cmak.fr
    Mar 7, 2020 at 6:24
  • Wrong logfile. Try the term log in the same dir.
    – user535733
    Mar 7, 2020 at 18:35

1 Answer 1


Make sure you are run as root. Use this command to check are there no packages contain "mysql" and "mariadb" remain installed.

dpkg --get-selections | grep mysql
dpkg --get-selections | grep mariadb

Example response:

libmariadb3:amd64               install
mariadb-client                  install
mariadb-client-10.4             install
mariadb-client-core-10.4            install
mariadb-common                  install
mariadb-server                  install
mariadb-server-10.4             install
mariadb-server-core-10.4            install

Purge all package which contain word "mariadb" and "mysql" and make sure it is mysql or mariadb package. Because maybe you will found other packages contain those words but it's not mariadb or mysql package (i.e php-mysql). Don't purge it! Just purge mysql and mariadb package.

apt-get purge *packagename*

Then clear with:

apt-get autoremove

And reboot if needed.

After that check are there still packages that contain word "mysql" and "mariadb". If thera are not yet. You can reinstall mariadb or mysql.

Good luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.