Bug #14422 LOAD DATA LOCAL INFILE errcode 13
Submitted: 28 Oct 2005 11:10 Modified: 31 Oct 2005 8:48
Reporter: Jordi Garcia Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / ODBC Severity:S1 (Critical)
Version:3.51.12 OS:Windows (Windows XP SP2)
Assigned to: CPU Architecture:Any

[28 Oct 2005 11:10] Jordi Garcia
Description:
I just updated the MySQL complete set. Downloaded and installed:

- MySQL 5.0.15
- Connector ODBC 3.51.12
- MySQL Administrator 1.1
- MySQL Query Browser 1.1.17

Then when trying to LOAD DATA LOCAL INFILE you get the error message:

[MySQL][ODBC 3.51 Driver][mysqld-5.0.15-nt]File 'C:\P.txt' not found (Errcode: 13)

...but the file exists and the same command works if not using ODBC (from MySQL Query Browser or Navicat for instance).

"perror 13" says "OS error code  13:  Permission denied" but this file has no access restrictions at all and there are no other processes working with it.

How to repeat:
Create "P.txt" in C:\ and try to execute this:

CREATE TEMPORARY TABLE Imported (
Line mediumint unsigned NOT NULL default 0,
TokenOrder tinyint unsigned NOT NULL default 0,
TokenId int unsigned NOT NULL default 0
) ENGINE = MEMORY;

# Here you'll get the errcode 13 (is it access denied?)
LOAD DATA LOCAL INFILE "C:/P.txt" INTO TABLE Imported 
LINES TERMINATED BY "\r\n";

DROP TABLE Imported;

The file "P.txt" looks like this:
1	0	1779
2	0	316
3	0	182
4	0	58
4	1	332
4	2	305
5	0	1287
6	0	266
7	0	1886
8	0	58
8	1	1341
9	0	90
9	1	71
9	2	305

Suggested fix:
Don't know.
[28 Oct 2005 11:11] Jordi Garcia
Sample text file

Attachment: P.txt (text/plain), 152.81 KiB.

[30 Oct 2005 9:27] Vasily Kishkin
Sorry...I was not able to reproduce the bug. Could you please create and attach your test case ? Or you can build and run  my test case. My test case is attached.
[30 Oct 2005 9:28] Vasily Kishkin
Test case

Attachment: test.c (text/plain), 4.16 KiB.

[30 Oct 2005 11:34] Jordi Garcia
I use Delphi 7 to do the testing.

Create a new ODBC Data Source Name called "Test_DSN" (check that it works properly) and run the attached application.
[30 Oct 2005 11:36] Jordi Garcia
Create a new ODBC DSN like this and check that it works

Attachment: Create a new ODBC DSN.gif (image/gif, text), 14.88 KiB.

[30 Oct 2005 11:59] Jordi Garcia
Test application compiled and sources (Delphi 7) Part 1

Attachment: Test.part1.rar (application/octet-stream, text), 190.00 KiB.

[30 Oct 2005 12:00] Jordi Garcia
Test application compiled and sources (Delphi 7) Part 2

Attachment: Test.part2.rar (application/octet-stream, text), 61.46 KiB.

[31 Oct 2005 8:48] Vasily Kishkin
I've got the follow message: "File loaded OK" and "Tested OK". There are not problems. I guess There can be a problem with permition of mysql service. But It is not MyODBC bug.
[31 Oct 2005 8:53] Jordi Garcia
Ok, I will reinstall everything from scratch and try again.

Thank you for your time and sorry for any inconvenience.
[1 Nov 2005 12:23] Jordi Garcia
After reinstalling everything (twice!) the same error still occurs.

This time I typed a script in MySQL Query Browser like this:

DROP TABLE IF EXISTS Imported;

CREATE TEMPORARY TABLE Imported (
Line mediumint unsigned NOT NULL default 0,
TokenOrder tinyint unsigned NOT NULL default 0,
TokenId int unsigned NOT NULL default 0
) ENGINE = MEMORY;

LOAD DATA LOCAL INFILE "C:/P.txt" INTO TABLE Imported LINES TERMINATED BY "\r\n";

SELECT * FROM Imported;

...and MySQL Query Browser said: File 'P.txt' not found (Errcode: 13)

Then I just removed the word LOCAL from the script and I ran correctly!

Conclusion:

- I don't think that there's something wrong in my instalation of the MySQL set.
- I don't think that there's something wrong with the ODBC driver.
- I works OK if using MySQL directly from command line.
- There should be something wrong with the connection to the server if LOCAL or so.
- I still can't tell why but LOAD DATA works only if the word LOCAL is not specified...
[2 Feb 2010 19:44] Steph March
Hi,
 I got the same problem. I found the solution.
make sure rights are : for directory where your data is residing 
drwxr-xr-x.
and the data file : -rwxr--r--
and in a X session, gnome or kde, Use konkeror or something to verify
rights.
It works for me...