MySql backup og restore

To backup from the command line of your shell account, log in and type the following at the prompt replacing USERNAME and DATABASE as described previously:

mysqldump -a -u USERNAME -p DATABASE > FILENAME.mysql

You will be prompted for your database password and then the DATABASE will be dumped to a plain-text file called FILENAME.mysql.

The resulting file, FILENAME.mysql, is a full backup with which you can fully restore your database in case of problems.
Restoring via the command line

Restoring from FILENAME.mysql is a three step process:

1.

Drop the database

mysqladmin -u USERNAME -p drop DATABASE
2.

Recreate the database

mysqladmin -u USERNAME -p create DATABASE
3.

Import the backup data

mysql -u USERNAME -p DATABASE < FILENAME.mysql

This entry was posted
on Friday, February 23rd, 2007 at 1:15 pm and is filed under Private.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.