Moving a MySQL Database by Command Line Interface
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!)
Comments
More on tar and zip a directory to a gz file
Tarring and gzipping a directory:
tar -cvf wsf.tar wsf2008.net
The tar command does not compress files automatically. You can compress tar files with:
tar -czvf wsf.tar.gz wsf.tar
Actually, I think just one step does it:
tar -czvf files.tar.gz files
And then uncompress a tarred directory:
tar -xzvf foo.tar.gz
http://www.redhat.com/docs/manuals/linux/RHL-7.2-Manual/getting-started-guide/s1-zip-tar.html
Post new comment