I've recently moved web servers, and the new web server has a different version of PHP.
New Server: PHP 5.5.3-1ubuntu2 (cli)
Old Server: PHP 5.3.10 (cli)
On the database server, my.cnf is set to allow local-infile.
I can use load data local infile from:
- HeidiSQL
- The command line client running on the new web server using --local-infile=1
- PHP, using PDO, from the old web server
However, when I try to connect from the new web server, using PHP with PDO, I get:
A database problem has occurred: SQLSTATE[42000]: Syntax error or access violation: 1148 The used command is not allowed with this MySQL version
php.ini:
[MySQL]
; Allow accessing, from PHP's perspective, local files with LOAD DATA statements
; http://php.net/mysql.allow_local_infile
mysql.allow_local_infile = On
PDO constructor:
$this->db_conn = new PDO("mysql:host=$host;dbname=$dbname;port=$port", $user, $pass, array(PDO::MYSQL_ATTR_LOCAL_INFILE => 1));
I've also tried ini_set('mysql.allow_local_infile', 1) and ini_set('mysql.allow_local_infile', true) in the PHP script.
The LOCAL keyword is needed because the files are hosted on the web server, not the database server.
What else does PHP 5.5 want from me?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…