Last active
June 30, 2023 09:44
-
-
Save probil/6498345a492e06accddc to your computer and use it in GitHub Desktop.
Import mysql database with progress bar and log on error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# import (with pv) | |
pv db_dump.sql | mysql -u <user> -p'<password>' <database> > error.log | |
# import (without pv) | |
mysql -u <user> -p'<password>' <database> < db_dump.sql > error.log | |
# export | |
mysqldump -u <user> -h <host> -p'<password>' <database> | pv > db_dump.sql | |
# export with progress | |
# ================== | |
# to get size you should run: | |
# > SELECT table_schema AS "Database", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema; | |
# ================== | |
mysqldump -u <user> -h <host> -p<password> <database> | pv --size 100m > db_dump.sql |
Hi @danjde
Just add empty -p
param and it will ask you password in the terminal
# asks for password in command line
mysqldump -u <user> -h <host> -p <database> | pv > db_dump.sql
Ah, well!
Thanks for your help, very appreciates ;-)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @probil and thanks for your useful gist.
Do you know if is it possible to run "pv" omitting the password from the command line? For security reason, I prefer to digit the password out of the command line.
I hope to be clear :)
Many thanks!
Davide
Italy