MySQL SOURCE command for importing large SQL files

MySQL SOURCE command for importing large SQL files

If you have a large database that you frequently dump and rebuild, you might want to consider using the mysql SOURCE command. In the past, with smaller databases, I have imported using the following method:

mysql -u root -p monkseal_development < monkseal_development.sql

However, if monkseal_development.sql is large, there’s a way to speed this up.

mysql --max_allowed_packet=128M -u root -p monkseal_development
....

mysql> SOURCE monkseal_development.sql

Or, if you are super lazy like me:

mysql --max_allowed_packet=128M -u root -p monkseal_development -e "SOURCE monkseal_development.sql"

This has the added benefit of displaying how many rows are imported. You can play with --max_allowed_packet parameter and determine what works right for you setup. MySQL SOURCE command for importing large SQL files