Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

LOAD DATA LOCAL INFILE

Status
Not open for further replies.

sirugo

Programmer
Aug 1, 2000
162
SE
I have a text file placed in the Users directory on a Mac, called 'data.txt'

I want to use a php-script to push data from that file into a MySQL table located on a remote server.

I first try the phpmyadmin tool to do this and it gives me the proper query lines that it used to succeed. But the filename/path itself (in the query) is said to be:

/tmp/phpNA1yy4w
instead of
/Users/data.txt
where the file really is located

LOAD DATA INFILE '/tmp/phpNA1y4w' INTO TABLE `mytable` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r'

When I do this several times the path changes but always with tmp as the folder. Looks like an encrypted filename. Data comes into the table as I was hoping.

But when I try to run the following query:
LOAD DATA INFILE '/Users/data.txt' INTO TABLE `mytable ` FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r'

I get (-1 lines inserted) as a result (note the '-' !) and nothing comes in to the table.

Maybe this is a security issue. Any suggestions?
 
Of course I mean that the query contains "LOCAL", like this

LOAD DATA LOCAL INFILE '/Users/data.txt' INTO TABLE mytable FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\r'

I tried to run it throug phpmyadmin and also through a separate php-script on the server. There's no error returned but I get:
Inserted rows: -1
 
OK, now I think I see what's intended.

The file must first be uploaded to the server in a local directory there, then imported using this command.

But can it be automated in any way?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top