mysql "load data infile" command gives error 1045

Web hosting discussion, programming, and shared and dedicated servers.
3 posts Page 1 of 1
by respect » Mon Oct 22, 2012 6:16 pm
I'm trying to allow batch uploads of .csv data to my MySQL database from users outside of my organization. I've set up a .cgi script (written in Rebol scripting language) to allow this, but get the following error when trying to actually process the MySQL "load data infile" command:

"Importing Converted Inventory"
{load data infile '/home/WWW_pages/respect/itsgreenerhere.com/batch-upload/bo/inventory-output1.csv' replace into table products fields terminated by ',' enclosed by '"' lines terminated by '\n'}
** User Error: ERROR 1045 : Access denied for user 'respect_loc-rw'@'%' (using password: YES)
** Near: insert db [{load data infile ? replace into table products fields terminated by ',' enclosed by '"' lines terminated by ...

The "/home/WWW_pages/respect/itsgreenerhere.com/" path is what is returned by the .cgi script when I ask what the current directory is.

Here is the listing of the directory that the file that the MySQL "load data infile" command is trying to load:

$ ls -alrt
total 716
drwxrwxrwx 4 respect user 4096 Oct 15 13:36 ..
-rw-r--r-- 1 respect user 339470 Oct 22 17:49 inventory.csv
drwxr-xr-x 2 respect www 4096 Oct 22 17:49 .
-rw-r--r-- 1 respect user 373555 Oct 22 17:49 inventory-output1.csv
_[Sonic:/home/r/respect/public_html/itsgreenerhere.com/batch-upload/bo]_

Incidentally, I've tried changing the path for the "load data infile" command from the aliased path to the path listed above in the directory listing, but got the same error.

The inventory-output1.csv file is uploaded through a form on my website.

I can perform all other MySQL commands like "insert", "select" and "delete" using the same credentials and the same .cgi script, but not the "load data infile" command.

Any ideas?
by augie » Tue Oct 23, 2012 5:18 pm
In this case you need to specify the "LOCAL" keyword:

http://dev.mysql.com/doc/refman/5.1/en/load-data.html

Although you may still not be able to load the data if you do not have the "FILE" permission set for your user.

It is probably easier to use PHPMyAdmin via the Member Tools to import your data:

https://members.sonic.net/databases/
by respect » Wed Oct 24, 2012 7:43 pm
OK, now I get the following:

My command sent to MySQL:
load data local infile '/home/r/respect/public_html/itsgreenerhere.com/batch-upload/bo/inventory-output1.csv' replace into table products fields terminated by ',' enclosed by '"' lines terminated by '\n'

MySQL's response:
** User Error: ERROR 1148 : The used command is not allowed with this MySQL version

The only thing I changed was added the "local" option before "infile" as per the docs.

The link you sent me to was for v5.1, but according to phpMyAdmin, it's running MySQL client version: 4.1.22. However, the "Local" statement also applies to 4.1 according to the online docs.

Again, I can't use phpMyAdmin to upload these files because they need to be uploaded by my clients, and I don't want to give them access to the database other than to upload their data.

Any ideas?
3 posts Page 1 of 1

Who is online

In total there are 14 users online :: 0 registered, 0 hidden and 14 guests (based on users active over the past 5 minutes)
Most users ever online was 999 on Mon May 10, 2021 1:02 am

Users browsing this forum: No registered users and 14 guests