Completely uninstall MariaDB – Debian 11

Note that the following steps will completely purge your MariaDB, configs and all other setup.

  1. Completely remove the current MariaDB package:

In the command below, note that purge has 2 hyphens in front of it.

sudo apt-get  --purge remove "mysql*"  
# Note that purge has 2 hyphens  in front of it.
  1. Remove the MariaDB configuration files:
sudo rm -rf /etc/mysql
  1. Remove the MariaDB data directory:
sudo rm -rf /var/lib/mysql

# You can also remove old log files
sudo rm -rf /var/log/mysql
  1. Remove the MariaDB system user and group:
sudo userdel -r mysql
sudo groupdel mysql

To reinstall mariaDB do:

sudo apt install mariadb-server mariadb-client

Start and enable (start at reboot) Mariadb

sudo systemctl start mariadb && sudo systemctl enable mariadb

Then secure it by following the prompts that follow from this command :

sudo mysql_secure_installation

Leave a Comment