As it's stated on their site, GeoNames geographical database covers all countries and contains over eight million placenames that are available for download free of charge. This database is available for download free of charge under a creative commons attribution license.
This importer script downloads all the tables available on Geonames.org and imports them into local MySQL database. Also it can be used to keep local database up to date by synchronizing it with Geonames.org. When running with a special option it downloads daily diff's and applies them to current database.
The basics of this script are quite simple:
importer.sh [OPTIONS] <action>
Where <action> can be one of the following:
config
--- register database parameters (mysql user's password will be prompted to save the file)init
--- initializes local MySQL databaseimport
--- downloads geonames data and imports them into local databaseupdate
--- updates database (usually should run daily by cron)empty
--- empty tables
Config options are:
-u <user>
--- username to access database-h <host>
--- MySQL server address (default:localhost
)-r <port>
--- MySQL server port (default:3306
)-n <database>
--- MySQL database name (default:geonames
)
importer.sh -u geonames -h localhost config
Enter password: secret
To create local database geonames
:
importer.sh -u root -p ROOT_PASSWORD init
To import geonames data into local geonames
database:
importer.sh import
To apply yesterday's changes in geonames.org to local database geonames
:
importer.sh update
To flush all geonames tables into local database:
importer.sh empty
Geonames database importer is Copyright © 2014 Ilya Konyukhov. It is free software and may be redistributed under the terms specified in the LICENSE file.