Cannot use LOAD DATA LOCAL INFILE with pdo

SQLSTATE[42000]: Syntax error or access violation: 1148 The used command is not allowed with this MySQL version

1) install the optimized native driver

sudo apt-get install php5-mysqlnd

2) In pdo connect set the local infile flag:

$conn = new PDO(“mysql:host=[host];dbname=[database];port=[port]“, username, password, array(PDO::MYSQL_ATTR_LOCAL_INFILE=>true));

NOTE: do not set local-file in my.cnf. mysql will fail to restart

Leave a comment

0 Comments.