Countries, States and Cities for MySQL
This is a clone of a post from my previous blog, a lot of people found the dump useful so I’ve transfered it over to the new blog.
Looking around the internet, I couldn’t find any good (free) database dumps for MySQL of all global cities by states by countries for MySQL. I’ve put my own together using free data from MaxMind. This database doesn’t have a lot of excess data (read: it fits the purpose that I was after, and that’s purely finding names by state/country).
The database contains three tables: countries (id, name, code), states (id, country_id, name, code) and cities (id, state_id, name, code). The database is using MaxMind’s city data of cities with a population of 15,000 of greater (they have data sets for cities of 1,000/5,000 or greater as well). I didn’t require that intense fidelity for this database.
Download the database (188kb, sql.bz2)
If anyone spots any obvious problems, please let me know. Also, if anyone is interested in the SQL and files used to construct this database I can clean them up and make them also available (the SQL file used to build the database works directly with the raw data files from MaxMind, so updating should be easy enough).