6 October 2015

mysql import show progress

Have you ever had to do bigger mysql import? If you do, you probably get annoyed by not being able to know how long it will take to complete. There is a command called "pv". Basically it allows a user to see the progress of data through a pipeline. You can get information such as time elapsed, percentage completed (with progress bar), current throughput rate, total data transferred, and ETA. To use it, insert it in a pipeline between two processes. Its standard input will be passed through to its standard output and progress will be shown on standard error. You can find the default output on the image.

Source code viewer
  1. # Old way, without visible progress tracing.
  2. mysql -uroot -p db_name < '~/Downloads/2015-10-06T14-38-42.sql'
  3. # Show progress while importing.
  4. pv '~/Downloads/2015-10-06T14-38-42.sql' | mysql -uroot -p db_name
Programming Language: Bash