User login

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!)

Searched words: 
zip gzip move copy transfer unzip backup database mysql load db via cli

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

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.