Sometimes you just want a database to run some queries against. Any reasonable set of tables with data pertaining to something not terribly complicated will do. Perhaps you have an urge to tease out the intricacies of correlated subqueries, or you need to test some complicated pattern matching functions. MySQL provides a database dump for such recreation, called “world”. The world database contains global population data from Statistics Finland. The data itself is several years old, but it works fine as general test fodder.
Since I normally only use it on my own machines for testing, I’ve found setting it up to be a fixed process. So I created this alias for such situations:
1 2 3 | alias setup_world_db="wget -O /tmp/world.sql.gz http://downloads.mysql.com/docs/world.sql.gz && \ gunzip /tmp/world.sql.gz && mysql -u root -p -e 'create database if not exists world;' && \ mysql -u root -p world < /tmp/world.sql && rm /tmp/world.sql" |
This pulls down the world database dump, unzips it, creates a DB to hold it, imports it, then removes the temporary files. You’ll be prompted twice for the password of the root MySQL user. You could also alter it to include the password if you are so inclined. Add the above alias line to ~/.bashrc, reload it, and you can have a test DB up and waiting within seconds anytime you want.
Possibly Related (no promises):
- Better access to MySQL create view statements
- Tune MySQL like a pro with MySQLTuner
- Advanced ordering of MySQL results
- Troubleshooting with MySQL binary logs
- Catching warnings from the MySQLdb module
Related posts brought to you by Yet Another Related Posts Plugin.








Pingback: Advanced ordering of MySQL results | tail -f findings.out
Pingback: Better access to MySQL create view statements | tail -f findings.out