HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to reset MariaDB into a "fresh install" state?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
installintofreshstatehowresetmariadb

Problem

I had InnoDB corruption and managed to start the server in read only mode and perform a fresh backup using innodb_force_recovery=5.

This way of starting the service puts the databases in read only mode, even deletion is disallowed.

Is there an official procedure to reset the whole server into a fresh installed (or at least "empty") version?

And in case there isn't, then what are the correct uninstall/reinstall steps to make sure there will be no remaining residues of data that could generate problems in the future?

Solution

MariaDB can be reverted to the fresh state by removing its data files.

Say if you run MariaDB on a Debian you can do the next:

systemctl stop mysql
rm -rf /var/lib/mysql/*
systemctl start mysql


At the start if no datafiles exists MariaDB will recreate the internal scheme mysql.* with all default values. All leftovers like config and log files you have to clean up by hands.

Code Snippets

systemctl stop mysql
rm -rf /var/lib/mysql/*
systemctl start mysql

Context

StackExchange Database Administrators Q#261932, answer score: 8

Revisions (0)

No revisions yet.