IP2Location™ LITE IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE Database (2024)

Introduction

IP2Location™ LITE IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE Database (1)

This database provides a solution to determine the country, region or state, city, latitude, longitude, and ZIP code of origin for any IP address in a few simple steps. First, retrieve the IP address from the networking protocol or server-side variable of the Web server. Next, translate the IP address to an IP number in decimal format to speed up the database query. Lastly, reverse lookup the IP number from the IP2Location™ database to pinpoint the exact geographical location.

It is free for personal or commercial use with attribution required by mentioning the use of this data as follows,

Please get the commercial edition if you are looking for high data accuracy, more records & customer support. Please visit product comparison page for more information.

Let's explore this database which provides a valuable resource of geolocation data for free now!

Sign Up For Free

Features

Translates IP address to country, region or state, city, latitude and longitude, and US ZIP code.

Current VersionJune 2024
Next UpdateJuly 2024
IPv4 Database SizeBIN: 81.54 MB
CSV: 305 MB (2,990,941 Rows)
IPv6 Database SizeBIN: 155.67 MB
CSV: 637.21 MB (4,917,788 Rows)
Database FormatBinary (BIN)
ASCII Text File (CSV)

Database Fields

NameTypeDescription
ip_fromINT (10) / DECIMAL (39,0)††First IP address show netblock.
ip_toINT (10) / DECIMAL (39,0)††Last IP address show netblock.
country_codeCHAR(2)Two-character country code based on ISO 3166.
country_nameVARCHAR(64)Country name based on ISO 3166.
region_nameVARCHAR(128)Region or state name.
city_nameVARCHAR(128)City name.
latitudeDOUBLE†††City latitude. Default to capital city latitude if city is unknown.
longitudeDOUBLE†††City longitude. Default to capital city longitude if city is unknown.
zip_codeVARCHAR(30)ZIP/Postal code.

IPv4
†† IPv6
††† Latitude and Longitude are often near the center of population. These values are not precise and should not be used to identify a particular address or household.

Database Setup

Below are the steps to set up the database for both IPv4 and IPv6 data.

  • IPv4
  • IPv6
  • MySQL
  • MS-SQL
  • PostgreSQL
  • MongoDB
Create Database
CREATE DATABASE ip2location;USE ip2location;CREATE TABLE `ip2location_db9`(`ip_from` INT(10) UNSIGNED,`ip_to` INT(10) UNSIGNED,`country_code` CHAR(2),`country_name` VARCHAR(64),`region_name` VARCHAR(128),`city_name` VARCHAR(128),`latitude` DOUBLE,`longitude` DOUBLE,`zip_code` VARCHAR(30),PRIMARY KEY (`ip_to`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Import Database
LOAD DATA LOCALINFILE 'IP2LOCATION-LITE-DB9.CSV'INTO TABLE`ip2location_db9`FIELDS TERMINATED BY ','ENCLOSED BY '"'LINES TERMINATED BY '\r\n'IGNORE 0 LINES;
Create Database
CREATE DATABASE ip2locationGOUSE ip2locationGOCREATE TABLE [ip2location].[dbo].[ip2location_db9]([ip_from] bigint NOT NULL,[ip_to] bigint NOT NULL,[country_code] nvarchar(2) NOT NULL,[country_name] nvarchar(64) NOT NULL,[region_name] nvarchar(128) NOT NULL,[city_name] nvarchar(128) NOT NULL,[latitude] float NOT NULL,[longitude] float NOT NULL,[zip_code] nvarchar(30) NOT NULL) ON [PRIMARY]GOCREATE CLUSTERED INDEX [ip_to] ON [ip2location].[dbo].[ip2location_db9]([ip_to]) ON [PRIMARY]GO
Import Database
BULK INSERT [ip2location].[dbo].[ip2location_db9]FROM '{PATH TO IP2LOCATION-LITE-DB9.CSV}'WITH(FORMATFILE = '{PATH TO DB9.FMT}')GO

NOTE: You will need to copy the FMT code below and save it as a file named DB9.FMT on your computer.

12.0101 SQLCHAR 0 1 "\"" 0 first_double_quote Latin1_General_CI_AI2 SQLCHAR 0 20 "\",\"" 1 ip_from "",3 SQLCHAR 0 20 "\",\"" 2 ip_to "",4 SQLCHAR 0 2 "\",\"" 3 country_code Latin1_General_CI_AI,5 SQLCHAR 0 64 "\",\"" 4 country_name Latin1_General_CI_AI,6 SQLCHAR 0 128 "\",\"" 5 region_name Latin1_General_CI_AI,7 SQLCHAR 0 128 "\",\"" 6 city_name Latin1_General_CI_AI,8 SQLCHAR 0 20 "\",\"" 7 latitude "",9 SQLCHAR 0 20 "\",\"" 8 longitude "",10 SQLCHAR 0 30 "\",\"" 9 zip_code Latin1_General_CI_AI
Create Database
CREATE DATABASE ip2location WITH ENCODING 'UTF8';\c ip2locationCREATE TABLE ip2location_db9(ip_from bigint NOT NULL,ip_to bigint NOT NULL,country_code character(2) NOT NULL,country_name character varying(64) NOT NULL,region_name character varying(128) NOT NULL,city_name character varying(128) NOT NULL,latitude real NOT NULL,longitude real NOT NULL,zip_code character varying(30) NOT NULL,CONSTRAINT ip2location_db1_pkey PRIMARY KEY (ip_from, ip_to));
Import Database
COPY ip2location_db9 FROM 'IP2LOCATION-LITE-DB9.CSV' WITH CSV QUOTE AS '"';
Import Database
mongoimport -u USERNAME -p PASSWORD --authenticationDatabase admin --drop --db ip2location --collection ip2location_db9 --type csv --file "IP2LOCATION-LITE-DB9.CSV" --fields ip_from,ip_to,country_code,country_name,region_name,city_name,latitude,longitude,zip_code
  • MySQL
  • MS-SQL
  • PostgreSQL
  • MongoDB
Create Database
CREATE DATABASE ip2location;USE ip2location;CREATE TABLE `ip2location_db9_ipv6`(`ip_from` DECIMAL(39,0) UNSIGNED,`ip_to` DECIMAL(39,0) UNSIGNED,`country_code` CHAR(2),`country_name` VARCHAR(64),`region_name` VARCHAR(128),`city_name` VARCHAR(128),`latitude` DOUBLE,`longitude` DOUBLE,`zip_code` VARCHAR(30),PRIMARY KEY (`ip_to`)) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
Import Database
LOAD DATA LOCALINFILE 'IP2LOCATION-LITE-DB9.IPV6.CSV'INTO TABLE`ip2location_db9_ipv6`FIELDS TERMINATED BY ','ENCLOSED BY '"'LINES TERMINATED BY '\r\n'IGNORE 0 LINES;
Create Database
CREATE DATABASE ip2locationGOUSE ip2locationGOCREATE TABLE [ip2location].[dbo].[ip2location_db9_ipv6]([ip_from] char(39) NOT NULL,[ip_to] char(39) NOT NULL,[country_code] nvarchar(2) NOT NULL,[country_name] nvarchar(64) NOT NULL,[region_name] nvarchar(128) NOT NULL,[city_name] nvarchar(128) NOT NULL,[latitude] float NOT NULL,[longitude] float NOT NULL,[zip_code] nvarchar(30) NOT NULL) ON [PRIMARY]GOCREATE CLUSTERED INDEX [ip_to] ON [ip2location].[dbo].[ip2location_db9_ipv6]([ip_to]) ON [PRIMARY]GO
Import Database
BULK INSERT [ip2location].[dbo].[ip2location_db9_ipv6]FROM '{PATH TO IP2LOCATION-LITE-DB9.IPV6.CSV}'WITH(FORMATFILE = '{PATH TO DB9.FMT}')GO

NOTE: You will need to copy the FMT code below and save it as a file named DB9.FMT on your computer. The first line of the FMT code indicates the version of bcp. Please change the version as according to your MS-SQL installed.

12.0101 SQLCHAR 0 1 "\"" 0 first_double_quote Latin1_General_CI_AI2 SQLCHAR 0 39 "\",\"" 1 ip_from "",3 SQLCHAR 0 39 "\",\"" 2 ip_to "",4 SQLCHAR 0 2 "\",\"" 3 country_code Latin1_General_CI_AI,5 SQLCHAR 0 64 "\",\"" 4 country_name Latin1_General_CI_AI,6 SQLCHAR 0 128 "\",\"" 5 region_name Latin1_General_CI_AI,7 SQLCHAR 0 128 "\",\"" 6 city_name Latin1_General_CI_AI,8 SQLCHAR 0 20 "\",\"" 7 latitude "",9 SQLCHAR 0 20 "\",\"" 8 longitude "",10 SQLCHAR 0 30 "\",\"" 9 zip_code Latin1_General_CI_AI
Create Database
CREATE DATABASE ip2location WITH ENCODING 'UTF8';\c ip2locationCREATE TABLE ip2location_db9_ipv6(ip_from decimal(39,0) NOT NULL,ip_to decimal(39,0) NOT NULL,country_code character(2) NOT NULL,country_name character varying(64) NOT NULL,region_name character varying(128) NOT NULL,city_name character varying(128) NOT NULL,latitude real NOT NULL,longitude real NOT NULL,zip_code character varying(30) NOT NULL,CONSTRAINT ip2location_db1_pkey PRIMARY KEY (ip_from, ip_to));
Import Database
COPY ip2location_db9_ipv6 FROM 'IP2LOCATION-LITE-DB9.IPV6.CSV' WITH CSV QUOTE AS '"';
Import Database
mongoimport -u USERNAME -p PASSWORD --authenticationDatabase admin --drop --db ip2location --collection ip2location_db9_ipv6 --type csv --file "IP2LOCATION-LITE-DB9.IPV6.CSV" --fields ip_from,ip_to,country_code,country_name,region_name,city_name,latitude,longitude,zip_code

AMI & Images

IP2Location provides a free, pre-configured & ready-to-run AMI and images to easily set up the database.

SDK & Libraries

C Library

PHP Module

Perl Module

Ruby Library

Python Library

Apache Module

Nginx Module

Node.js Module

Cocoa / Objective C Library

Pascal Library

D Library

Go Package

Erlang Module

Lua Package

Haskell Package

Debian Package

.NET Component

Java Component

HTTP Module

ActiveX/COM-DLL

Scala

IP2Location™ LITE IP-COUNTRY-REGION-CITY-LATITUDE-LONGITUDE-ZIPCODE Database (2024)
Top Articles
Latest Posts
Article information

Author: Cheryll Lueilwitz

Last Updated:

Views: 6064

Rating: 4.3 / 5 (74 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Cheryll Lueilwitz

Birthday: 1997-12-23

Address: 4653 O'Kon Hill, Lake Juanstad, AR 65469

Phone: +494124489301

Job: Marketing Representative

Hobby: Reading, Ice skating, Foraging, BASE jumping, Hiking, Skateboarding, Kayaking

Introduction: My name is Cheryll Lueilwitz, I am a sparkling, clean, super, lucky, joyous, outstanding, lucky person who loves writing and wants to share my knowledge and understanding with you.