Monday, January 25, 2010

Restore a MySQL database from backup file

First, create an empty database:
CREATE DATABASE new_database_name;

Use this syntax to restore:
$mysql -u root -p new_database_name < backup_file_name.sql

Note that this mysql command run from the folder you install MySQL, for example: C:\Program Files\MySQL\MySQL Server 5.1\bin
The following command I run from my computer to restore vtigercrm510 database from its backup file vtigercrm510bk.sql:
CREATE DATABASE vtigercrm;
C:\Program Files\MySQL\MySQL Server 5.1\bin>mysql -u root -p vtigercrm < rm510bk.sql

No comments:

Post a Comment