简体   繁体   中英

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!

尝试加载数据本地文件

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM