MySQL how to recover data from an old disk?

0

Issue

Is it possible that I can recover data from mySQL ubuntu server? I needed to change a disk in my server so I installed a new ubuntu, but in my old disk I still have files in /var/lib/mysql/ where my old databases are. Is it possible to recover a database from files? How to do it? Just copying database from old disk /var/lib/mysql/ to a new server disk? Will it work instantly or I need to create first empty databases in phpmyadmin?

Solution

If the data is still here it´s promising for your recovery.

1/. You need to back up this /var/lib/mysql directory

sudo cp -R -p /var/lib/mysql /var/lib/mysql.back

2/. Reinstall completely mysql (it will erase the mysql folder)

sudo apt-get install mysql-server

3/. Erase the new data folder with your old one

sudo cp -R -p /var/lib/mysql.bask /var/lib/mysql

If you´re using exactly same directories it should work like that.

Answered By – hackela

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More