IP2Location™ LITE IP-COUNTRY-REGION-CITY Database

介紹

IP2Location LITE Database

該數據庫提供了一個解決方案,只需幾個簡單的步驟即可確定任何IP地址的國家,地區或州以及來源城市。首先,從網絡協議或Web服務器的服務器端變量中檢索IP地址。接下來,將IP地址轉換為十進制格式的IP地址,以加快數據庫查詢的速度。最後,從IP2Location™數據庫中反向查找IP號,以查明確切的地理位置。

它是免費的,但需註明出處並註明出處,如下所述,

如果您希望獲得更高的數據準確性,更多記錄和客戶支持,請獲取商業版。請訪問產品比較頁面以獲取更多信息。

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

Sign Up For Free

特徵

將IP地址轉換為國家,地區或州和城市。

當前版本 November 2024
下次更新 December 2024
IPv4 數據庫大小 BIN: 47.01 MB
CSV: 212.24 MB (2,998,507 行)
IPv6 數據庫大小 BIN: 105.1 MB
CSV: 512.11 MB (5,151,441 行)
大批 二進制 (BIN)
ASCII文本文件 (CSV)

數據庫字段

名稱 類型 描述
ip_from INT (10) / DECIMAL (39,0)†† 第一個IP地址顯示netblock。
ip_to INT (10) / DECIMAL (39,0)†† 上一個IP地址顯示netblock。
country_code CHAR(2) 基於ISO 3166的兩個字符的國家/地區代碼。
country_name VARCHAR(64) 基於ISO 3166的國家/地區名稱。
region_name VARCHAR(128) 地區或州名稱。
city_name VARCHAR(128) 城市名。

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.

數據庫設置

以下是為IPv4和IPv6數據設置數據庫的步驟。

建立資料庫
CREATE DATABASE ip2location;
USE ip2location;
CREATE TABLE `ip2location_db3`(
	`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),
	PRIMARY KEY (`ip_to`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
導入數據庫
LOAD DATA LOCAL
	INFILE 'IP2LOCATION-LITE-DB3.CSV'
INTO TABLE
	`ip2location_db3`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 0 LINES;
建立資料庫
CREATE DATABASE ip2location
GO

USE ip2location
GO

CREATE TABLE [ip2location].[dbo].[ip2location_db3](
	[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
) ON [PRIMARY]
GO

CREATE CLUSTERED INDEX [ip_to] ON [ip2location].[dbo].[ip2location_db3]([ip_to]) ON [PRIMARY]
GO
導入數據庫
BULK INSERT [ip2location].[dbo].[ip2location_db3]
FROM '{PATH TO IP2LOCATION-LITE-DB3.CSV}'
WITH
(
	FORMATFILE = '{PATH TO DB3.FMT}'
)
GO

注意:您將需要復制以下FMT代碼並將其保存為計算機上名為DB3.FMT的文件。

12.0
7
1 SQLCHAR 0 1 "\"" 0 first_double_quote  Latin1_General_CI_AI
2 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

建立資料庫
CREATE DATABASE ip2location WITH ENCODING 'UTF8';
\c ip2location
CREATE TABLE ip2location_db3(
	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,
	CONSTRAINT ip2location_db1_pkey PRIMARY KEY (ip_from, ip_to)
);
導入數據庫
COPY ip2location_db3 FROM 'IP2LOCATION-LITE-DB3.CSV' WITH CSV QUOTE AS '"';
導入數據庫
mongoimport -u USERNAME -p PASSWORD --authenticationDatabase admin --drop --db ip2location --collection ip2location_db3 --type csv --file "IP2LOCATION-LITE-DB3.CSV" --fields ip_from,ip_to,country_code,country_name,region_name,city_name
建立資料庫
CREATE DATABASE ip2location;
USE ip2location;
CREATE TABLE `ip2location_db3_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),
	PRIMARY KEY (`ip_to`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
導入數據庫
LOAD DATA LOCAL
	INFILE 'IP2LOCATION-LITE-DB3.IPV6.CSV'
INTO TABLE
	`ip2location_db3_ipv6`
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\r\n'
IGNORE 0 LINES;
建立資料庫
CREATE DATABASE ip2location
GO

USE ip2location
GO

CREATE TABLE [ip2location].[dbo].[ip2location_db3_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
) ON [PRIMARY]
GO

CREATE CLUSTERED INDEX [ip_to] ON [ip2location].[dbo].[ip2location_db3_ipv6]([ip_to]) ON [PRIMARY]
GO
導入數據庫
BULK INSERT [ip2location].[dbo].[ip2location_db3_ipv6]
FROM '{PATH TO IP2LOCATION-LITE-DB3.IPV6.CSV}'
WITH
(
	FORMATFILE = '{PATH TO DB3.FMT}'
)
GO

注意:您將需要復制以下FMT代碼並將其保存為計算機上名為DB3.FMT的文件。 FMT代碼的第一行指示bcp的版本。請根據安裝的MS-SQL更改版本。

12.0
7
1 SQLCHAR 0 1 "\"" 0 first_double_quote  Latin1_General_CI_AI
2 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

建立資料庫
CREATE DATABASE ip2location WITH ENCODING 'UTF8';
\c ip2location
CREATE TABLE ip2location_db3_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,
	CONSTRAINT ip2location_db1_pkey PRIMARY KEY (ip_from, ip_to)
);
導入數據庫
COPY ip2location_db3_ipv6 FROM 'IP2LOCATION-LITE-DB3.IPV6.CSV' WITH CSV QUOTE AS '"';
導入數據庫
mongoimport -u USERNAME -p PASSWORD --authenticationDatabase admin --drop --db ip2location --collection ip2location_db3_ipv6 --type csv --file "IP2LOCATION-LITE-DB3.IPV6.CSV" --fields ip_from,ip_to,country_code,country_name,region_name,city_name

AMI和圖像

IP2Location提供了一個免費的,預先配置且可立即運行的AMI和映像,可輕鬆設置數據庫。

執照

請查看通用條款和條件中的數據庫許可。

IP2Location™ IP地址地理位置數據庫

在商業版中,您將獲得的不僅僅是IP地址查找:

  • 更高的數據準確性
  • 訪問最新數據庫
  • 通過電子郵件獲得更多支持
Product Upgrade
Sign Up Pop Out

Geolocate Your Visitors Location

Enhance your applications with essential geolocation data by using our FREE databases.