14

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?

1 Answer 1

15

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.

7
  • 1
    I would be careful to do step 2 above before step 1. You want to make sure that the install and starting of mysqld doesn't overwrite your old system database.
    – malcolmpdx
    Mar 22, 2011 at 22:54
  • That's a good point. I assumed that /var/lib/mysql was not from the original installation. In any case, yes make sure your original files are not at /var/lib/mysql before you start this. You want to start with a fresh Mysql instance before you start trying to load your original data.
    – kashani
    Mar 22, 2011 at 23:06
  • thank you I slightly modified the step to adapt to my Zend Server CE & MacOS environement and it works!
    – John
    Mar 22, 2011 at 23:36
  • @Kashani i followed these instructions (centos) but on new server i get the table to show up but the data and table don't.. any ideas? i see all of the tables inside the folder they just don't show up (it also looks like it's the right character set)
    – K2xL
    Apr 28, 2012 at 18:11
  • 2
    @K2xL I'm not sure what you're seeing. If you create a new question with the details of what you're seeing and how you accomplished it, I'd be happy to look at it. Keep in mind that the method above only works for the whole Mysql installation, not individual database because Innodb tables have data stored in the main ibdata files regardless of whether you're using innodb_file_per_table or not.
    – kashani
    Apr 29, 2012 at 19:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .