0

Good afternoon.

My Debian 9 server ran into an issue that rendered the OS inaccessible , I managed to extract all the raw database files (/var/lib/mysql) for my project but unfortunately the engine type was set to InnoDB.

Is there any chance I can somehow recover the database? Thanks.

1

If you have the entire /var/lib/mysql then you should probably try completely replacing the current contents of /var/lib/mysql with the content you have.

Depending on your mariadb/mysql options some or all of the innodb data is global and stored in the /var/lib/mysql/ibdata1, and /var/lib/mysql/ib_logfile files. So just restoring the /var/lib/mysql/databasename/table* will usually not be enough to restore innodb data.

You could temporarily move the current current contents of that directory to another location if you already have restored or started using that. Or even better temporarily start up a new machine in a VM or something where you can test restoring the entire /var/lib/mysql directory without interrupting anything.

After placing your old data in /var/lib/mysql you should be able to start the server and hopefully extract your data. You may need to start mariadb with the options to bypass privileges depending on how locked down your privileges were. I wouldn't continue to use that though, instead I would suggest at that point you use mysqldump or your favorite tools to dump the database, then re-import it into your production database.

As you move things back and for make sure that the mysql/mariadb service account (normally mysql/mysql) owns and has read-write access to all the files.

  • Thank you for the information. What would be the correct approach of dropping the old /var/lib/mysql content into a new MariaDB installation, ie by adding the files before the MariaDB package is installed or by stopping the server and replacing the existing files? – Kjell Sep 3 '18 at 11:52
  • 1
    I would probably install mariadb, stop the daemon, then move files around. – Zoredache Sep 3 '18 at 22:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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