📜 ⬆️ ⬇️

Base GeoIP - countries and cities, December 2011

An updated version of the Russian-language database of countries and cities has been published. The main change - removed a large number of duplicate cities.

The database is distributed in two versions: “ Countries and cities ” (23Mb, after installing ~ 130Mb) and “ Countries only ” 2Mb, after installing ~ 12Mb). Also in the archives is a small example of using the database in php.

The accuracy of determining the country ~ 99%, the accuracy of determining the cities on average ~ 95%. Whether it is a lot or a little depends on the tasks that you are going to solve with the help of this base.
')
Test demo - determine your country and city by IP-address

Work demo - city ​​substitution in the form of air ticket search

To install the database, I recommend using programs like mysqldumper or via ssh to execute
mysql –p –user database <file.sql

The “ update script ” (~ 300Kb, after installing ~ 1Mb) is adapted only for the current version of the database (December 2011), it is impossible to update with the previous versions with its help . To update the database, import the geo_update_2011_12.sql file (contains two technical tables), download the latest archives with maxmind and ipgeobase and run update_maxmind.php and update_ru.php from the console. Update maxmind database of cities takes 20-30 minutes.

In the directory of countries there are islands that are not independent states, but significantly removed from their metropolitan areas.

In the directory of cities errors are possible (including duplicates).

In the “Only countries” database there are IP blocks of only European countries (from ipgeobase, net_euro table) and countries around the world (including European, from maxmind, net_country_ip table). Theoretically, European countries should be more accurately determined by the first option, but there was no practical test.

Ideas to improve and improve the quality of the base are welcome.

If while testing the demo you found an error - report the verified IP address.

Some statistics


In the current version of the base 87,501 settlements.

The number of settlements in different countries:
A countryamount
USA28,991
Germany16,264
Australia4,871
France4.613
Spain3,253
Canada3,074
Brazil2,926
Russian Federation2.301
Switzerland1,831
Mexico1,572
Portugal1,349
Ireland1.269
Argentina1,189
Japan851
Poland712
Italy699
Bulgaria659
Great Britain652
Colombia540
Ukraine531
Belgium447
China401
Luxembourg387
India365
Austria346
Turkey306
Serbia293
South Africa292
Chile281
Hungary269
Kazakhstan266
New Zealand262
Czech216
Romania215
Algeria190
Croatia170
Venezuela144
Belarus138
Moldova129
Greece128
Peru126
Lithuania115
Estonia115
Sweden113
The Republic of Korea112
Guatemala108
Philippines101
Israel99
Latvia93
Salvador92
Netherlands88
Iran87
Puerto rico82
Ecuador78
Dominican Republic75
Costa Rica74
Morocco73
Slovakia70
Indonesia69
Pakistan67
Honduras66
Trinidad and Tobago63
Mauritius61
Finland59
Bosnia and Herzegovina59
Uruguay52
Nigeria52
Macedonia51
Egypt50
Jamaica50
Panama49
Tunisia48
Paraguay47
Ivory Coast45
Armenia44
Nicaragua40
Vietnam38
Barbados38
Slovenia37
Malaysia37
Uzbekistan34
Iraq31

In other countries, less than 30 localities.

Added by:
Fixed a bug in the definition of some Russian and Ukrainian cities.

Source: https://habr.com/ru/post/135596/


All Articles