If you want an empty and new mariadb installation ( or just want to reset the data dir to a default state ), and don’t want to ‘purge’ the installation first you can do it simply:
First stop your mariadb/mysql server with:
systemctl stop mariadb.service
Then if you want to reset the database and choose a default root password:
**WARNING WILL REMOVE ALL YOUR TABLES**
mysqld --initialize
If you don’t want to choose a root password:
**WARNING WILL REMOVE ALL YOUR TABLES**
mysqld --initialize-insecure
Sources:
https://stackoverflow.com/questions/8911115/how-to-recover-recreate-mysqls-default-mysql-database
https://dev.mysql.com/doc/refman/8.0/en/server-options.html