CREATE TABLE IF NOT EXISTS `cities` (
`Country` CHAR(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`City` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`AccentCity` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`Region` CHAR(2) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
`Population` INT(10) UNSIGNED NOT NULL,
`Latitude` FLOAT NOT NULL,
`Longitude` FLOAT NOT NULL,
KEY `AccentCity` (`AccentCity`(5)),
KEY `City` (`City`(5))
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
LOAD DATA LOCAL INFILE http://www.mywebsite.com/worldcitiespop.txt
INTO TABLE `cities`
FIELDS
TERMINATED BY ','
LINES
TERMINATED BY '\n'
IGNORE 1 LINES;
各位大家好,我从MaxMind的网站http://www.maxmind.com/app/worldcities下载了一个世界城市数据库。大概是160MB。现在的问题是我不能把它放在我的数据库中。该文本包含超过200万行,它的开头如下:
Country,City,AccentCity,Region,Population,Latitude,Longitude
ad,aixas,Aixàs,06,,42.4833333,1.4666667
ad,aixirivali,Aixirivali,06,,42.4666667,1.5
ad,aixirivall,Aixirivall,06,,42.4666667,1.5
查询有什么问题?
答案 0 :(得分:0)
我不知道MySQL在LOAD DATA INFILE
中有任何能力通过你所指示的URL。您可以LOAD DATA INFILE
使用服务器上的文件,或LOAD DATA LOCAL INFILE
使用客户端计算机上的文件,但两者都不允许您提供URL并让MySQL执行HTTP请求来获取文件。