用LOAD DATA LOCAL infile导入文件,文件是存在本地的,但是导入却报 file xxxx not found (Errcode: 13) 的错误,想不明白。
解决方案 »
- mysqld-nt 启动不了
- 谁做过数据库表的分割,多少行能用的到分割?分割的利与弊?
- 如何解决:mysql-gui-tools-5[1].0-r9a-win32不支持中文件的问题?
- my.cnf参数疑问
- 怎么写一个触发器让后面ID跟着减1(在线等 急急急!!! 高手们帮帮忙!)
- 复合索引的问题,建立复合索引对字段数有什么限制吗?
- MYSQL提示说:incorrect integer value,我大致查了一下,说是因为MYSQL5的BUG,高手能详细说下吗?谢谢~~
- 统计查询问题
- 求按日取出当日最大值的语句
- net start mysql发生系统错误2 ,找不到指定文件?求各位的大神指导
- mysql排序分组新问题(求救各位sql高手)
- 求个UPDATE的SQL语句,把一行信息的2个字段增加到一个字段里
begin
FOwner.FLogIntf.DoAddLog(Self, '批量导入 '+task.DatFile);
name:= Q_ReplaceStr(task.DatFile, '\', '\\') ;
sql := Format(SQL_LOAD_DATA,[name, task.TabName]);
if 0 <> mysql_real_query(FLibHandle, PAnsiChar(sql), Length(sql)) then
begin
line := mysql_error(FLibHandle);
FOwner.FLogIntf.DoAddLog(Self, line );
end
else
begin
FOwner.FLogIntf.DoAddLog(Self, sql+'.OK.');
//导入成功才删除
FOwner.FLogIntf.DoAddLog(Self, '删除文件 '+task.DatFile);
DeleteFileA(PAnsiChar(task.DatFile));
end;
end;
if FileExists(task.DatFile) then
begin
FOwner.FLogIntf.DoAddLog(Self, '批量导入 '+task.DatFile);
name:= Q_ReplaceStr(task.DatFile, '\', '\\') ;
sql := Format(SQL_LOAD_DATA,[name, task.TabName]);
if 0 <> mysql_real_query(FLibHandle, PAnsiChar(sql), Length(sql)) then
begin
line := mysql_error(FLibHandle);
FOwner.FLogIntf.DoAddLog(Self, line );
end
else
begin
FOwner.FLogIntf.DoAddLog(Self, sql+'.OK.');
//导入成功才删除
FOwner.FLogIntf.DoAddLog(Self, '删除文件 '+task.DatFile);
DeleteFileA(PAnsiChar(task.DatFile));
end;
end;
导入失败记录的日志(括号中是SQL):
导入失败:(LOAD DATA LOCAL infile 'C:\\省标服务\\轨迹\\MyData\\gps_2011_06_01_103024_0001.txt' IGNORE into table gps_2011_06 lines terminated by '\r\n' )File 'C:\省标服务\轨迹\MyData\gps_2011_06_01_103024_0001.txt' not found (Errcode: 13)把一个导入失败的SQL拿出来执行也没问题:Query OK,1024 rows affected(0.03 sec)
试试
这个拿出来执行都没错的
复制少了一段
下,测试一下能否通过
mysql> LOAD DATA LOCAL infile 'C:\\省标服务\\轨迹\\MyData\\gps_2011_06_01_103024_0001.txt' IGNORE into table gps_2011_06 lines terminated by '\r\n' Query OK,1024 rows affected(0.03 sec)
_0041.txt' IGNORE into table gps_2011_06 lines terminated by '\r\n' 在程序中执行也是同样报错的):
Microsoft Windows [版本 5.2.3790]
(C) 版权所有 1985-2003 Microsoft Corp.C:\Documents and Settings\Administrator>mysql -h localhost -u root -p
Enter password: ***
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 37
Server version: 5.1.51-community MySQL Community Server (GPL)Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 licenseType 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use track
Database changed
mysql> LOAD DATA LOCAL infile 'F:\\省标服务\\轨迹\\MyData\\gps_2011_06_01_103355
_0041.txt' IGNORE into table gps_2011_06 lines terminated by '\r\n' ;
Query OK, 1021 rows affected (0.06 sec)
Records: 1024 Deleted: 0 Skipped: 3 Warnings: 0mysql>
下,测试一下能否通过确定是否是中文的问题
放在你的程序中试一下。sql := "LOAD DATA LOCAL infile 'F:\\省标服务\\轨迹\\MyData\\gps_2011_06_01_103355_0041.txt' IGNORE into table gps_2011_06 lines terminated by '\r\n' ;";
if 0 <> mysql_real_query(FLibHandle, PAnsiChar(sql), Length(sql)) then
begin如果有问题则再试一下。sql := "LOAD DATA LOCAL infile 'F:\\\\省标服务\\\\轨迹\\\\MyData\\\\gps_2011_06_01_103355_0041.txt' IGNORE into table gps_2011_06 lines terminated by '\r\n' ;";
into table gps_2011_06 lines terminated by '\r\n' ;
Query OK, 0 rows affected (0.01 sec)
Records: 1024 Deleted: 0 Skipped: 1024 Warnings: 0
LOAD DATA LOCAL infile 'F:\\省标服务\\轨迹\\MyData\\gps_2011_06_01_103355_0041.txt' IGNORE into table gps_2011_06 lines terminated by '\r\n' .OK.按照你说的试了下导入成功,导入确实是有时失败有时成功的,而且有个特点,程序和MYSQL在同部机器导入成功率高,程序和MYSQL不同部机器导入成功率相对低一点。