Recover MySQL Data From Files

Overview

The best way to backup and restore from MySQL is using Workbench or mysqldump however this may not be possible if the system is trashed but have HDD data in tact. As a last resort the files can be recovered and restored.

Files

In Ubuntu 10.04 and 12.04 the database files are stored in /var/lib/mysql. Each schema has it’s own directory named after the schema.

First stop MySQL service:
sudo service mysql stop

Copy the directories to the new computer but exclude the mysql folder or it will cause issues.

Start MySQL again:
sudo service mysql start

Once restored it’s best to perform a backup and re-create the tables to prevent any file permission issues.

Summary

A quick and easy way of recovering database from file system.

About Danny

I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog.

Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise.

Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school.

View all posts by Danny → This entry was posted in Database, Linux and tagged , , , , . Bookmark the permalink.

Leave a Reply