The most common back up solution is phpMyAdmin, and some people prefer it over any built-in method. To export via phpMyAdmin, we:
1. Navigate to the database
2. Switch to the export tab
3. Select all tables and SQL as the export type
4. Under options on the right-hand side select Disable foreign key checks
5. Select save as file at the very bottom of the page
6. If we want to match the compression type of Magento’s output, select gzipped as our compression method
7. Click the Go button to export
This will give us an SQL file, which we can then import at a later date back into an empty database and restore our data.
To restore data from phpMyAdmin there can be some error occure. To avoid such error we can add following code in my sql file.
Add this code at the beginning of our sql file:
SET NAMES utf8;
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE=’NO_AUTO_VALUE_ON_ZERO’;
SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0;
At the end of the file, add the statements required to turn on constraint checking again:
With these modifications, you should be able to restore your database from a .sql file backup created with any tool.
If you have similar problems installing the sample database, just add the same statements to the .sql file containing the sample data.