Pipe gunzip and mysql to gunzip a dump and import it
743
Solution 1
zcat foo.sql.gz | mysql -uroot -ppassword foo
This will also leave foo.sql.gz
as it is.
Solution 2
For those on Max OSX there is a bug with zcat
so you'll need to use gzcat
instead.
gzcat foo.sql.gz | mysql -uroot -ppassword foo
Solution 3
All other answers are recommending writing the password in the command. This is a very bad practice and poses security risks. Please DON'T DO that.
You can leave the password empty in the command, than it will ask you to enter the password interactively. This way the password is not saved in the bash history.
gunzip < dump.sql.gz | mysql -u username -p databasename
Related videos on Youtube
![Vlad](https://lh5.googleusercontent.com/-RmQefVhusuA/AAAAAAAAAAI/AAAAAAAAAGs/kHmWYBZldO8/photo.jpg?sz=256)
Author by
Vlad
Updated on September 18, 2022Comments
-
Vlad almost 2 years
How can font-awesome be upgraded for shiny on a mac?
Here it is for windows
shinydashboard some Font Awesome Icons Not Working
However I couldn't find any folders resembling the windows solution on the mac.
-
thefreeman over 11 yearsFYI you really do not want to pass the mysql password on the command line. This leads to it being stored in ~/.bash_history for all to see. If you just put -p it will prompt you to enter your password which is much safer (and doesn't break the zcat pipe either)
-
iacnats over 11 yearsYou orignal command would work if gunzip < foo.sql.gz | mysql -uroot -ppassword foo
-
-
podarok over 8 yearsIn terms of speed this works much more slower than gunzip && mysql -e "use unzipped.sql".