0

The system is Fedora 32. Mariadb was installed and operational; it is now necessary to reinitialize Mariadb and all data and users.

I removed mariadb-server and mariadb and erased /etc/my.cnf and my.cnf.d. I then reinstalled mariadb and mariadb-server and ran the mysql_secure_installation script. It found the original root password but otherwise completed normally.

I then logged into mariadb. I expected to find the users from the original installation had been removed; however they had not.

show databases; shows the original tables. They were not removed.

select * from mysql.user; showed the original users.

How can mariadb be completely removed including all users, data, and passwords?

2 Answers 2

1

You need to delete the data in your datadir, since that is where this is stored. The default location is /var/lib/mysql/. Shut down MariaDB and delete everything inside the datadir without deleting the datadir itself (as you want to avoid having to recreate the directory with exactly the right permissions):

sudo systemctl stop mariadb
sudo rm -rf /var/lib/mysql/*

Then use mysql_install_db to re-initialise the datadir.

2
  • Thank you. That worked through to 'systemcth start mariadb.service'. It errored with: Process: 1390711 ExecStart=/usr/libexec/mysqld --basedir=/usr $MYSQLD_OPTS $_WSREP_NEW_CLUSTER (code=exited, status=1/FAILURE)
    – dan sawyer
    Nov 21, 2020 at 23:46
  • Second update: Somehow in that process the directory /var/lib/mysql ended up being owned by root. Changing it to mysql allowed mariadb to initialize.
    – dan sawyer
    Nov 22, 2020 at 13:19
0

For each of the user,host from select user,host from mysql.user;

DROP USER '{user}'@'{host}'

If there are non-system database (exclude 'mysql', 'information_schema' and 'performance_schema'), in SHOW DATABASES they can be removed with `DROP DATABASE'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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