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.
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.
A quick and easy way of recovering database from file system.