Portal Home > Knowledgebase > Articles Database > MySQL restore a DB


MySQL restore a DB




Posted by quad3datwork, 05-13-2010, 06:14 PM
I found a DB from a backup that I needed to restore it on a MySQL server. Can I just extract the DB into existing MySQL instance and restart MySQL? For example, I have the zipped /var/lib/mysql/DB1 from backup. Do I just unzip it into the new server under /var/lib/mysql/DB1?

Posted by InoxHost, 05-13-2010, 06:19 PM
You need to use following command given that you must know username and password for that certain database.

Posted by quad3datwork, 05-13-2010, 07:15 PM
This is not a "dumped" DB. I have the .MYD, .MYI, and .frm files all in flat/raw.

Posted by dnki, 05-13-2010, 07:57 PM
The control panel usually has options to import databases.

Posted by kelepirci, 05-14-2010, 01:09 AM
Interesting question. I would try MySql community forum for the answer. As I know, raw mysql files are encrypted. You can not just replace the files for them to work properly. But there should be a solution. As mysql forums.

Posted by Kohrar, 05-14-2010, 03:24 AM
I've tried that before just to see what happens and it worked. But you really shouldn't unless you have no other choice. Keep in mind that I tried this using the same MySQL server version. Copying the data files directly especially when MySQL isn't shutdown can cause your restored database to be inconsistent since things on the server might not have been completely flushed to disk yet.

Posted by madaboutlinux, 05-14-2010, 04:23 AM
Yes, it will work. Just overwrite the existing .MYI, .MYD, and .frm files with the backup you have OR move the current files elsewhere and copy these files from the backup and restart the mysql service.

Posted by quad3datwork, 05-14-2010, 11:44 AM
That's badass! I can't get to it now, will try later.

Posted by devonblzx, 05-14-2010, 04:33 PM
As long as the files weren't in use when they were backed up the .MYI and .MYD files will work to restore from. If a table was being updated when the backup was taken there could be corruption which is why it may be smarter to use mysqldump to take backups rather than the myisam files themselves.

Posted by Crashus, 05-16-2010, 06:09 AM
They will work, there might be some codepage problems but still it will be fine.



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
How do i do this????? (Views: 651)
PCI Issue (Views: 690)