Hello,

I installed MySQL 5.1 on a local machine, under C:\Programs\MySQL\MySQL Server 5.1 (on WindowsXP).

Now I'm trying to use LOAD DATA INFILE sql command (MySQL :: MySQL 5.1 Reference Manual :: 12.2.6 LOAD DATA INFILE Syntax) to load some data from a textual file (with a predefined format) directly into a table of a given database.

I noticed a weird behaviour. If the textual file from which I want to load data is under C: and the path in the sql command is specified as an absolute path, everything works fine. For example:

LOAD DATA INFILE 'C:\\mysql_test\\myfile.txt' INTO TABLE mytable ...
(double backslashes for windows compliance)

However, for personal needs, the files from which I have to load data, they have to be located in some local directory under C:, but they have to be accessed from MySQL by a network drive mapping. To be more clear, following the example above, the data file myfile.txt is located in C:\mysql_test and I defined a network drive mapping W: that is mapped on C:\mysql_test, so the file can be accessed through W:\myfile.txt.
So the file "myfile.txt" is located in C:\mysql_test
There is a network drive mapping W: pointing to C:\mysql_test
I can access the data file through W:\myfile.txt.
Remember also that for the moment, all these things are locally accessed!

So I modified the sql command in this way:

LOAD DATA INFILE 'W:\\myfile.txt' INTO TABLE mytable ...

But this does not works, giving back a "file not found" error message.

The reference manual says that this command is executed on the server and so all the paths specified have to be referred to the server.
This sounds correct to me, but in my case the server is installed locally and the path I used (W:\\myfile.txt) is absolute! Why the server doesn't find it?

The reference manual describes also the usage of the "local" option. It forces the data file to be searched in the client filesystem and not in the server.
This seems to be "a kind of solution to a kind of bug", as written here: MySQL Bugs: #20271: LOAD DATA INFILE doesn't work with networked drive in WIN environment.

Well, I tried it, and the command become:

LOAD DATA LOCAL INFILE 'W:\\myfile.txt' INTO TABLE mytable ...

and... suspance... it works!
But why?!?! This is perfectly correct if I'm connecting from my client application to a remote mysql server. But this is not the case! Here client and server are in the same machine. So why only the client application process (the console in my case) can see W:\myfile.txt?

And now the incredible ending. Say that my local ip is 85.46.176.249, so I can specify the path to the myfile.txt data file as "\\85.46.176.249\mysql_test\myfile.txt". The sql command become:

LOAD DATA INFILE '\\\\85.46.176.249\\mysql_test\\myfile.txt' INTO TABLE mytable ... (the double backslashes are for windows compliance)

This work!!! And there's no "local" option specified! No words.

Please help me!