Agaric Design Collective

Moving a MySQL Database by Command Line Interface

By Benjamin Melançon
on 04 Dec
1 comment

Key words and phrases

zip gzip move copy transfer unzip backup database

Tags

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

 

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-...

Posted by Benjamin Melançon on Thu, 2008-03-06 16:24
Post new comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <blockquote> <h1> <h2> <h3> <h4> <h5> <h6> <small> <pre> <strike> <sub> <sup> <kbd> <s>
  • Lines and paragraphs break automatically.
  • Web page addresses and e-mail addresses turn into links automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Copy the characters (respecting upper/lower case) from the image.