IP Address Geolocation From MySQL

In this short tutorial I will use a local MySQL database to do IP addresses geolocation.

First download the database from this page: http://blogama.org/node/58

And then go in your favorite MySQL interface and type:

SELECT * FROM `ip_group_city` where `ip_start` <= 4881709 order by ip_start desc limit 1;

IP addresses use this format (example IP A.B.C.D):

ip = (A*256+B)*256+C

For example, if you have an ip of (Google):

It would become in the database:

ip = (74*256+125)*256+45 = 4881709
Share this page:

Suggested articles

9 Comment(s)

Add comment


By: Anonymous


It is nice way to know the ip address location through my sql.I like this.

But i got information about the ip address from this http://www.ip-details.com/ only.It is also very helpful for me.It contains more information about this ip address.

By: IT Magazines

Are you sure about the accuracy?

By: Anonymous

Best site for IP Geo Location for me is www.myiptest.com


Hi, the data is very accurate, around 99.8% accuracy. I updated it monthly.


By: micie

How accurate it is? As the IP locator: http://www.ip-adress.com

If yes, i will give it a try.

By: Anonymous

I found a new site to check out IP Address details through

By: amzul

hey Marc thanks for your work.

can you please specify a way on how to use your rsync server?

  rsync --verbose --progress --stats --update rsync://rsync.ipinfodb.com/ipinfodb /tmp/downloads/sql/

i can see that there are some files but cant synchronized them.



By: Anonymous

How does the database compare to those commercial providers such as http://www.ip2location.com/ which are currently using by banks and government?

By: China Wholesale

I will use a local MySQL database to do IP addresses geolocation.