Afdb6aa91430febdaea8020479bb4208

Just wondering if this is the best way to do this when, for example, you need to restore a database dump on a server, but the unzipped file is too large for the disk quota...

gunzip -c database_dump.sql.gz | mysql -u username -h host -ppassword database

Refactorings

No refactoring yet !

5a00a3a98dcf6f9cd717440fd2b606e5

Eineki

February 11, 2009, February 11, 2009 09:03, permalink

No rating. Login to rate!

To me this solution is quite good, nothing to object :)

Be1e3ee645d23c95ba650c21bc885927

Fabien Jakimowicz

February 12, 2009, February 12, 2009 12:36, permalink

No rating. Login to rate!

Not really better, but you save a few keystrokes.

zcat database_dump.sql.gz | mysql -u username -h host -p password database
A8d3f35baafdaea851914b17dae9e1fc

Adam

February 12, 2009, February 12, 2009 21:12, permalink

1 rating. Login to rate!

I suppose you could take advantage of the network if the dumps are stored elsewhere. Otherwise, there is nothing wrong with what you are doing.

ssh -C user@host 'mysql -u username -h host -p password database' < database_dump.sql
8bfe810a30e352e3632733dd839c1220

Ross Kendall

June 14, 2009, June 14, 2009 15:29, permalink

No rating. Login to rate!

If the database is not on the local machine it may be helpful to use the --compress option to speed up the transfer of data over the network.

here is my example, with an added example of creating a dump as well

P.S. I don't understand the benefit of the previous post?

mysqldump --opt --compress -u username -h host -ppassword database | gzip -c > database_dump.sql.gz
gunzip -c database_dump.sql.gz | mysql --compress -u username -h host -ppassword database

Your refactoring





Format Copy from initial code

or Cancel