22

How do I completely remove MariaDB so I can reset the root password?

Zanna
  • 72,471
  • 5
    Sorry? What does the 1st have to do with the 2nd? And even if you did mean to reset the password for connecting to the database and not the root password: what does that have to do with removing mariadb? – Rinzwind Aug 03 '16 at 08:23
  • 1
    and how did you install mariadb? apt-get? source tarball? – Rinzwind Aug 03 '16 at 08:27
  • I used apt-get I need to pretty much reset all the passwords to it but think Ive broken it to the stage a complete reset is easier than doing it manually – SteamPunk_Devil Aug 03 '16 at 08:34
  • 1
    Re-installing the packages won't reset the database or its configuration though. This sounds like an XY Problem. I think your question would be better along the lines of: “I broke my MariaDB installation and probably need to reset its root password. So far I tried […] to achieve that but it wasn't successful/seems to have made things worse. How can I proceed?” I won't vote to close it as unclear because there's a helpful answer though. – David Foerster Aug 04 '16 at 10:13

2 Answers2

42

First, create a backup of {database}:

mysqldump -u {user} -p {database} > /home/$USER/Documents/backup.sql

To remove any trace of mariadb installed through apt-get:

sudo service mysql stop
sudo apt-get --purge remove "mysql*"
sudo rm -rf /etc/mysql/ 

and it is all gone. Including databases and any configuration file.

To check if anything named mysql is gone do a

sudo updatedb

and a

locate mysql

It should be fairly empty (maybe some manual pages or a connector). If though you see a my.cnf amongst the results remove that too.

Zanna
  • 72,471
Rinzwind
  • 310,127
-1

This is what worked for me on Kali Linux:

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

Remove all the packages found by the above commands.

sudo dpkg --force depends --purge mysql-common   

I found these libraries:

libdbd-mariadb-perl             install
libmariadb-dev                  install
libmariadb-dev-compat               install
libmariadb3:amd64               install
libmariadbd-dev                 install
libmariadbd19:amd64             install
mariadb-backup                  install
mariadb-client                  install
mariadb-client-core             install
mariadb-common                  install
mariadb-plugin-provider-bzip2           install
mariadb-plugin-provider-lz4         install
mariadb-plugin-provider-lzma            install
mariadb-plugin-provider-lzo         install
mariadb-plugin-provider-snappy          install
mariadb-server-core             install
mariadb-test-data   
default-libmysqlclient-dev:amd64        install
default-libmysqld-dev:amd64         install
default-mysql-client-core           install
mysql-common                    deinstall
python3-mysqldb                 install

To remove them run

sudo apt autoremove                                        
sudo apt autoclean

If any conflict comes up, you can use the dpkg command to remove a package and then reinstall if needed.

Zanna
  • 72,471