MySql backup og restore

Það er ágætt að kunna þetta.. 🙂 og að setja það hér er fín leið til muna eftir þessu:

———–

Backing up via the command line

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

One Response to “MySql backup og restore”

  1. Remote Server Backup

    #mysqldump –host=the.remotedatabase.com -u yourusername -p yourdatabasename > /Users/rick/backups/foo.sql

Leave a Reply

You must be logged in to post a comment.