Skip to content

Instantly share code, notes, and snippets.

@probil
Last active June 30, 2023 09:44
Show Gist options
  • Save probil/6498345a492e06accddc to your computer and use it in GitHub Desktop.
Save probil/6498345a492e06accddc to your computer and use it in GitHub Desktop.
Import mysql database with progress bar and log on error
# 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
@danjde
Copy link

danjde commented Aug 19, 2019

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