LOAD DATA LOCAL INFILE forbidden in... PHP
Check docs http://php.net/manual/en/ref.pdo-mysql.php.
Basically you need:
PDO::MYSQL_ATTR_LOCAL_INFILE => true
Set at instantiation.
Example:
$conn = new \PDO("mysql:host=$server;dbname=$database;", "$user", "$password", array( PDO::MYSQL_ATTR_LOCAL_INFILE => true, ));
I didn't get the exact error you get, but you need no ensure the following:
Enable by adding to your my.cnf:
[mysql]local-infile=1[mysqld]local-infile=1
Tell the connection in PHP that it may use LOCAL INFILE
Using mysql:
mysql_connect(server,user,code,false,128); // 128 enables LOCAL INFILEmysql_select_db(database);
Using mysqli:
$conn = mysqli_init();mysqli_options($conn, MYSQLI_OPT_LOCAL_INFILE, true);mysqli_real_connect($conn,server,user,code,database);
Give MySQL user FILE permission
When using LOCAL this shouldn't be necessary, though. LOCAL says that the file is located on the client server (where you have PHP is installed), otherwise it looks at server location (where MySQL is installed).
GRANT FILE ON *.* TO 'mysql_user'@'localhost'