PDO import CSV, "LOADDATALOCALINFILE" error Solution

Source: Internet
Author: User
No error code is returned when importing csv files from a local wamp: Repeated replace=tablenewcardcharactersetutf8fieldsterminatedbyenclosedbylinesterminatedbyrn ('code ')

No error code is returned when importing csv files from the local wamp: load data infile '/opt/htdocs/www/reply replace into table newcardCHARACTER SET utf8FIELDS terminated by ''encodingby' \ "'Lines terminated by' \ r \ n' ('Code ') upload

No error code is returned when importing csv files from the local wamp:

LOAD DATA INFILE  '/opt/htdocs/www/xxx.com/xxx/public/upload/53a7d83f00e08b4f0121d80f.csv' REPLACE INTO  TABLE newcardCHARACTER SET utf8FIELDS TERMINATED BY '' ENCLOSED BY '\"'LINES TERMINATED BY '\r\n' (`code`)

Reported when uploaded to the server

Access denied.

Later I checked the cause because the database server and the file server are not on the same machine and need to use "LOAD DATA LOCAL INFILE ".

So I changed the code

LOAD DATA LOCAL INFILE  '/opt/htdocs/www/xxx.com/xxx/public/upload/53a7d83f00e08b4f0121d80f.csv' REPLACE INTO  TABLE newcardCHARACTER SET utf8FIELDS TERMINATED BY '' ENCLOSED BY '\"'LINES TERMINATED BY '\r\n' (`code`)

ReportWarning: PDO: exec (): load data local infile forbidden in/opt/htdocs/www/xxx.com/xxx/public/test.php on line 12

Later, google launched a solution in load-data-local-infile-forbidden-in-php.

You can solve the problem by passing the following parameters during pdo initialization.

\PDO::MYSQL_ATTR_LOCAL_INFILE => true

Reprinted, please note: the blog of Jesus. Pan» PDO import CSV, "load data local infile" error Solution

The error message "load data local infile" is returned when PDO imports CSV files. It was first published in the blog of Jesus. Pan.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.