9

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?

1 Answer 1

10

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/*
sudo -u mysql mysql_install_db 
systemctl start mysql

For some versions of Debian, the mysql_install_db step is not necessary; when starting up 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 manually.

6
  • 7
    Maybe this is different on Debian, but I think you have to run mysql_install_db before you start it up again - at least that is my experience on Redhat/Fedora/CentOS.
    – dbdemon
    Commented Mar 15, 2020 at 12:58
  • 1
    @dbdemon On debian and freebsd (at least) start scripts invoke it automatically if no system db was found at datadir
    – Kondybas
    Commented Mar 15, 2020 at 14:59
  • 1
    My Debain 11 did not automatically invoke mysql_install_db . It is easy enough to check: ls /var/lib/mysql/mysql . If there is no directory it didn't run. Commented Dec 6, 2021 at 0:55
  • 2
    On debian 10, I called /var/lib/dpkg/info/mariadb-server-10.3.postinst configure to recreate "mysql" database Commented Jul 1, 2022 at 8:01
  • Thanks @dbdemon -- I forgot about mysql_install_db and MariaDB didn't want to start on macOS for me. After running the command it went on fine.
    – dimitarvp
    Commented Jan 5 at 19:53

Your Answer

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

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