如何在Mysql数据库中加载文件......? [英] How to load file in Mysql database...?
问题描述
我最近从ipage.com购买了虚拟主机,现在我想将Maxmind世界城市数据库插入到我的mysql数据库中。
我从以下网址下载文本文件:http://www.maxmind.com/en/worldcities [ ^ ]名为worldcitiespop.txt。
下载完成后,我将该文件插入到我的网站主机的根目录中。 />
因此,链接如下所示: http://www.example.com/worldcitiespop.txt
现在我首先使用此命令创建表和行:
I recently bought web hosting from ipage.com, Now i want to insert Maxmind world cities database into my mysql database.
I download the text file from: http://www.maxmind.com/en/worldcities[^] named "worldcitiespop.txt".
After downloading complete i insert that file into the root directory of my web host.
So, the link look like this: http://www.example.com/worldcitiespop.txt
Now first i use this command to create table and rows:
CREATE TABLE cities (
country CHAR(2),
city_ascii VARCHAR(100),
city VARCHAR(255),
region CHAR(2),
population INT UNSIGNED,
latitude DECIMAL(10, 6),
longitude DECIMAL(10, 6),
INDEX idx_lat_long (latitude, longitude),
INDEX idx_country (country),
INDEX idx_region (region)
);
成功后表和行创建我使用此命令将数据加载到行中:
After the success of table and rows creation i use this command to load data into rows:
LOAD DATA LOCAL INFILE 'worldcitiespop.txt' INTO TABLE cities
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(country, city_ascii, city, region, population, latitude, longitude);
但是在这一点上它给了我错误:
#2 - 找不到文件'worldcitiespop.txt'(错误代码:2)。
我也提供该文件的链接,但它再次给我错误。
我在我的电脑上也测试了这个代码,它的工作非常好。
请帮助我....
谢谢。
But at that point it gives me the error:
#2 - File 'worldcitiespop.txt' not found (Errcode: 2).
I also provide the link of that file but it again gives me the error.
I test this code also on my PC its works perfectly.
Please help me....
Thanks.
推荐答案
最好联系iPage支持,例如这家伙做了什么 [ ^ ]
You would be better off contacting iPage support like this guy did[^]
文件路径称为文档根
这篇关于如何在Mysql数据库中加载文件......?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!