How to Restore MySQL Database from Physical Files

backup-restorationMySQL

I just reinstalled my system, I didn't do dump backup but I still have the physical folder of my previous mysql installations.

Is possible to use it to restore and update my current configuration?

Best Answer

It's possible, but not suggested. If I were going to attempt it, here's how I'd do it.

  1. Install mysql, configure as close to the old server as possible or just use the same config. Make sure it starts, restarts, and you can log into it. Now shut mysql down.

  2. Move the old installation out of the way with mv /var/lib/mysql /var/lib/mysql.orig

  3. rsync or copy the new files into place. sudo rsync -av /old/mysql/ /var/lib/mysql/ I suggest keeping the original files in their current state in case this doesn't work.

  4. sudo chown -R mysql: /var/lib/mysql and then start mysql. Check the logs, make sure things look good, and then log into Mysql. Poke around make sure it looks like your data is there.

Assuming it all went smoothly you should be set. Now immediately go make a proper back of Mysql so you don't have to do this sort of nonsense next time.

Related Topic