⬆️ ⬇️

Base GeoIP - countries and cities, June 2011 (+ update script)

An updated version of the Russian-language database of countries and cities has been published. Major changes:

- due to the new base ipgeobase.ru, the accuracy of determining the cities of Ukraine has improved

- cities have disappeared from the free version of geobaza.ru; therefore, the accuracy of determining cities in other CIS countries has decreased

- added a script with which you can independently update the database (without adding new cities and countries)

- the net_ru_2 and net_su tables have been removed from the database, the sample queries have been changed

The result of this work is available for free download.



The database is distributed in two versions: “ Countries and cities ” (21Mb, after installing ~ 122Mb) and “ Countries only ” 2Mb, after installing ~ 13Mb). 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 definition by IP in the form of 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 (June 2011), it is impossible to update with the help of the previous versions . To update the database, import the geo_update_2011_06.sql file (contains two technical tables), download the latest archives with maxmind and ipgeobase (see readme.txt) and run update_maxmind.php and update_ru.php from the console. When updating the maxmind database of cities, ~ 4 million selects and ~ 2 million insert s are performed, so the operation requires considerable resources and time (~ 30-60 minutes). 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.



Some statistics



In the current version of the base 94,615 settlements.



The number of settlements in different countries:

A countryamount
Germany18,468
USA15.798
Italy6,645
Austria6,417
Spain5,721
Australia5,134
France4,651
Russian Federation3.287
Canada3,027
Poland2,844
Brazil2,342
Switzerland1.814
Belgium1,589
Japan1,445
Portugal1,289
Ireland1,128
Argentina1,086
Mexico1,069
Ukraine800
China724
Bulgaria615
Great Britain585
Colombia545
India359
Luxembourg359
South Africa333
Norway330
Turkey304
New Zealand280
Hungary262
Serbia221
Chile203
Kazakhstan194
Philippines188
Czech176
Romania171
The Republic of Korea166
Slovakia161
Sweden159
Netherlands157
Croatia141
Ecuador141
Finland134
Guatemala126
Venezuela123
Honduras121
Belarus102
Iran96
Greece96
Lithuania95
Israel91
Latvia89
Estonia85
Moldova85
Trinidad and Tobago79
Peru69
Barbados56
Jamaica56
Costa Rica56
Indonesia56
Dominican Republic53
Mauritius52
Denmark51
Egypt46
Morocco43
Macedonia41
Armenia40
Nigeria39
Vietnam38
Algeria38
Uruguay36
Panama36
Salvador33
Sloveniathirty
Malaysiathirty


In other countries, less than 30 localities.



Posted 09/06/2011

Optimized script update database maxmind, the operation is faster and consumes less computational resources. Thanks shushu for helpful advice.

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



All Articles