Wednesday, October 8, 2008

Backup and restore mysql data....Example.

The example I was taught goes simply like this:

mysql>mysqldump -u root -p DATABASENAME > DATABASENAME.sql

If you wanted to test it, you could drop the database:

mysql>DROP DATABASE DATABASENAME;
(DATABASE referring to DATABASENAME, the one you just backed up)

The quit mysql:

mysql>q

Log back in:

]$ mysql -u root -p
mysql>CREATE DATABASE PREVIOUS_DATABASENAME;
mysql> \q
Bye
]$ mysql -u root -p PREVIOUS_DATABASENAME < DATABASENAME.sql
Enter password:


And it will be restored!


No comments:

 
Custom Search