Search code examples
phpmysqlgeolocationgeocodingmaxmind

PHP - How to use GeoLite2 IP CSV databases in MySql?


How do you get the CSV databases of GeoLite2 City and Country to work?

I have seen you must import it into a table. However I have seen some people takeout the IPv6 addresses. I have also seen some people attempt to combine both the blocks and the location databases...

What I want to do is take an IP and get the GPS coordinate and the City, State, Country data.

What table structure should I use? Once the data is imported how to I do a lookup using a PHP page?


Solution

  • I was able to figure it out... I removed all IPv6 IP records. Then I calculated the start and ending IP ranges and figured out where the IP fit in there. After that it was self explanatory.