It’s handy, fast, and convienient to you mysql on the command line. Lately, what I’ve been using it most for is to back up and restore databases. I don’t do it often enough to have the commands committed to memory, but everytime I need it I go searching for it again. Rather than trying to find my previous search results again I’ll post them here with a summary.
To back a mysql database into a gzipped archive:
mysqldump [database] | gzip > backup.sql.gz
To restore the backup:
gunzip < backup.sql.gz | mysql [database]
Reference: web cheat sheet
This article was last updated on: 08 Apr 2008