gunzip -c database_dump.sql.gz | mysql -u username -h host -ppassword database
Refactorings
No refactoring yet !
Eineki
February 11, 2009, February 11, 2009 09:03, permalink
To me this solution is quite good, nothing to object :)
Fabien Jakimowicz
February 12, 2009, February 12, 2009 12:36, permalink
Not really better, but you save a few keystrokes.
zcat database_dump.sql.gz | mysql -u username -h host -p password database
Adam
February 12, 2009, February 12, 2009 21:12, permalink
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
Ross Kendall
June 14, 2009, June 14, 2009 15:29, permalink
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
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...