Mysql backing up and restoring a database

From Teknologisk videncenter
Revision as of 08:23, 19 February 2009 by Heth (talk | contribs) (New page: == Backing up a mysql database == Following example will backup a database called wikidb to a file /home/backup/wikidbbackup02152009-13:34.dump <source lang="bash"> mysqldump -u USERNAME ...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Backing up a mysql database

Following example will backup a database called wikidb to a file /home/backup/wikidbbackup02152009-13:34.dump

mysqldump -u USERNAME -pPASSWORD --default-character-set=latin1 wikidb -c > /home/backup/wikidbbackup`date +%d%m%Y-%H:%M`.dump

Restore a mysql database

If the database do not exist in mysql, first create an empty database

 MISSING
mysql -u USERNAME -pPASSWORD wikidb < /home/backup/wikidbbackup02152009-13:34.dump