如何从位于服务器中的文本文件将数据导入mysql数据库[重复]
This question already has an answer here:
i am successful to import data from my local pc but the problem is,it is not working on the server here is the code that works fine when i load the file from pc directory
LOAD DATA LOCAL INFILE 'C:/test.txt' INTO TABLE pet fields terminated by ',';
but it doesn't work when i put server location like
LOAD DATA LOCAL INFILE 'http://localhost/farzana/erp_fiat/files/test.text' INTO TABLE pet fields terminated by ',';
it will be very helpful if someone fix this problem
</div>
此问题已经存在 这里有一个答案: p>
-
当文件是另一个位置时如何使用LOAD DATA INFILE语句?
1回答
span>
li>
ul>
div>
我成功了 从我的本地电脑导入数据,但问题是,它不在服务器上工作\从我的pc目录加载文件时代码工作正常 p>
LOAD DATA LOCAL INFILE'C:/test.txt'INTO TABLE pet字段由','; code> pre>
终止,但是当我把服务器位置放置时它不起作用 p>
LOAD DATA LOCAL INFILE'http://localhost/farzana/erp_fiat/files/test.text'IN TO TABLE宠物字段由','; code> pre>
终止,如果有人解决此问题,这将非常有用 p> div>
replace test.text
with test.txt
in the url and paste the URL in the browser if you can see the file,
else use the absolute path of the directory, instead of the URL
Remove LOCAL if you are loading it from server.
LOAD DATA INFILE 'http://localhost/farzana/erp_fiat/files/test.txt' INTO TABLE pet fields terminated by ',';
According to this answer:
When you do a LOAD DATA INFILE, the file must be on the system that is running the MySQL database, in the data path.
If the file is on your system, add the LOCAL keyword.
Try to remove the LOCAL
key word.