Moving a MySQL Database by Command Line Interface
Key words and phrases
zip gzip move copy transfer unzip backup databaseTags
Description
mysqldump -u root -p internetbar_live > internetbar_backup.sql
(should gzip here)
This command compresses the file database.sql and replaces it -- deletes it -- with the compressed .gz file database.sql.gz
gzip database.sql
scp ben@66.135.41.18:~/internetbar_backup.sql internetbar_backup.sql
On the other end if you compressed, uncompress:
gunzip database.sql.gz
Note: tar is for making an archive of multiple files.
Create a new database of the proper name first or be four million percent certain you want to replace an existing one. Triple-check that you are on the right server, also.
mysql -u root -p agaricroot_test < agaricroot_backup.sql
(Instead of root, you can use the database username and password. And again, this will overwrite the database named agaricroot_test without asking! Be very careful!)

Tarring and gzipping a directory:
tar -cvf wsf.tar wsf2008.netThe tar command does not compress files automatically. You can compress tar files with:
tar -czvf wsf.tar.gz wsf.tarActually, I think just one step does it:
tar -czvf files.tar.gz filesAnd then uncompress a tarred directory:
tar -xzvf foo.tar.gzhttp://www.redhat.com/docs/manuals/linux/RHL-7.2-Manual/getting-started-...