Recreate Mysql Database From FRM Files and Idb
Recreate Mysql Database From FRM Files and Idb
2 1
Recreate mysql database from frm files and idb
#mysql #mariadb #devops
Recently, I made a huge mistake on my server and ended up with a failed install and
no backups.
I basically had plesk with several wordpress sites and by chance, I still had access to
my data, even though it was not useable anymore.
So here is how I did to recover my files and be able to get back a .sql file with
structure and data.
First, retrieve data
So all my mysql data is lying on my server in /var/lib/mysql and it's organized in
ibdata1 (one important file to keep)
one folder per database name
inside each of this folder, and files
.frm .idb
mkdir mysql
scp -r root@<ip>:/var/lib/mysql/* .
For this, we launch docker on port 3307 just in case another mysql server is already
running.
Now, we can login to the database by using our favorite mySQL explorer, for me, it's
Sequel Pro
You can connect to the database using
Host: 127.0.0.1
username: root
password: Password123!
port: 3307
🎉 you got now the same version of mysql you used to have on your server.
Copy your old databases to the docker machine
So now, let's move each database inside docker to be able to access it:
docker cp dbname/ mariadbtest:/var/lib/mysql
From there, if you refresh your databases in Sequel Pro, you should see your
database but an error occurs when you try to open any table.
Table 'dbname.mod844_icl_string_status' doesn't exist for example
Fix errors
In order to fix this, you need to copy the previous file we backed up:
docker cp ibdata1 mariadbtest:/var/lib/mysql
After that, restart your docker machine and you should be able to access your data
using Sequel Pro.