NinaNa
NinaNa

Reputation: 1647

LOAD DATA INFILE error

I have csv file exported from access. (dates formatted to match mysql)

I need to import the data into a mysql DB through code.

when I import the file through PhpMyAdmin it worked beautifully.

$fname = $_FILES['sel_file']['name'];
$filename = $_FILES['sel_file']['tmp_name'];
$sql="LOAD DATA INFILE '../filepath/data.txt' INTO TABLE table1 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\"';";
 mysql_query($sql)or die(mysql_error());

I tried using the file path or using the variable $filename and both gave me the same error

I get the following error:

Access denied for user 'uname'@'%' (using password: YES) I set the permissions to be 777, The databse was created allowing direct access. (I am able to opload the file and read from it using an "INSERT" statement, but not load data.)

A. Is the LOAD DATA statement wrong?

B. What other things do I have to take care of in order to use the LOAD DATA command.

Thank you all!

Upvotes: 1

Views: 898

Answers (2)

thavan
thavan

Reputation: 2429

Try LOAD DATA LOCAL INFILE

Upvotes: 3

Muthu Krishnan
Muthu Krishnan

Reputation: 1658

It may be a authentication problem. Please check the permissions for Import/export data in mysql.

Upvotes: 0

Related Questions