Recover SQL database with directories only

Posted May 9, 2021 229 views

Somehow my DO backups of my working were all corrupt – I had to revert from a backup and none of them would complete. Not looking for reason why now.

Using DO’s tools, I was able to boot a generic instance with the backup as a drive. I was able to go to the MySQL folder and download all the directories of all my databases. But, I can find no way to get them, or one of them, into a new instances database, which requires a .sql file to import.

Any bright ideas to get these directories into the form that I can import them please? Thank you.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there,

I’ve faced that MySQL problem in the past with another provider. What I did to fix the problem was:

  • Created a fresh new server and installed the exact same MySQL version as the old one

  • Then stopped MySQL on that new server:

systemctl stop mysql
  • Again on the new server rename the /var/lib/mysql to /var/lib/mysql-backup:
mv /var/lib/mysql /var/lib/mysql-backup
  • Then copy the mysql folder from your backup to the freshly created server and add it to the /var/lib/mysql directory.

  • After that set the owner of the files and folders to the mysql user:

chown -R mysql:mysql /var/lib/mysql
  • Finally start MySQL and repair the tables if needed

Let me know how it goes.

  • Excellent idea. I may have thought to create the new server, but I wouldn’t have thought to create the same SQL version.

    Since many of the databases were separately backed up (with Akeeba), I have most sites online. I may vary from your instructions, to try an export of the one database I didn’t have well backed up. See if that imports after getting the .sql made.

    Many thanks. I’ll let you know.

    • Hi there,

      Ah yes, if you have the chance to export the databases in .sql format it would be a much cleaner solution.

      Hope that you get it all sorted!