|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-09-20 09:49 UTC] stefan dot kaifer at hartmann dot info
Description:
------------
Hello
I've compiled php myself with this command:
./configure --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd ....
Now my php-applications can't use
"LOAD DATA LOCAL INFILE '/tmp/import-20110919173927-78613.txt' INTO TABLE ..." anymore!
On the command prompt I can use "LOAD DATA LOCAL INFILE", that means mysql server allows me to use "LOAD DATA LOCAL INFILE", the server variable "local infile" is setted to "ON" (with "local-infile=1" in the my.cnf).
It seems a php-mysqlnd problem. Neither the mysql nor the mysqli extensions allows me to use "LOAD DATA LOCAL INFILE". This is the Connect-line in my code:
$Connect = mysql_connect($DB_Host .":".$DB_Port,$DB_User,$DB_Password, FALSE, 128);
The error is:
#1148 - The used command is not allowed with this MySQL version
Mysql-server: 5.5.16
PHP: 5.3.8
PHP-MYSQL-client: mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $
PHPINFO:
mysql
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $
Directive Local Value Master Value
mysql.allow_local_infile On On
mysql.allow_persistent Off Off
mysql.connect_timeout 60 60
mysql.default_host no value no value
mysql.default_password no value no value
mysql.default_port no value no value
mysql.default_socket no value no value
mysql.default_user no value no value
mysql.max_links Unlimited Unlimited
mysql.max_persistent Unlimited Unlimited
mysql.trace_mode Off Off
mysqli
MysqlI Support enabled
Client API library version mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $
Active Persistent Links 0
Inactive Persistent Links 0
Active Links 0
Directive Local Value Master Value
mysqli.allow_local_infile On On
mysqli.allow_persistent On On
mysqli.default_host no value no value
mysqli.default_port 3306 3306
mysqli.default_pw no value no value
mysqli.default_socket no value no value
mysqli.default_user no value no value
mysqli.max_links Unlimited Unlimited
mysqli.max_persistent Unlimited Unlimited
mysqli.reconnect Off Off
mysqlnd
mysqlnd enabled
Version mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $
Compression supported
SSL supported
Command buffer size 4096
Read buffer size 32768
Read timeout 31536000
Collecting statistics Yes
Collecting memory statistics No
Tracing n/a
I hope, that somebody can help.
Best regards
Stefan
Test script:
---------------
$Connect = mysql_connect($DB_Host .":".$DB_Port,$DB_User,$DB_Password, FALSE, 128);
$StrSQL = "LOAD DATA LOCAL INFILE '/tmp/test.txt' INTO TABLE testtable
FIELDS TERMINATED BY '</td><td>' LINES
STARTING BY '<tr><td>'
TERMINATED BY '</td></tr>'
IGNORE 1 LINES .....";
$Result1 = mysql_db_query($DB,$StrSQL,$Connect);
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 27 06:00:01 2025 UTC |
So, what is this report about? If it's on ext/mysql, I call it not a bug. Thus, closing. If config is correct, things work just fine. ---------- $host = "localhost:/var/run/mysql/mysql.sock"; $user = "root"; $pass = ""; $flags = 128; $db = "test"; printf("PHP %s\n", PHP_VERSION); $file = getcwd() . DIRECTORY_SEPARATOR . "foo.txt"; if (!($fp = fopen($file, "w"))) die(sprintf("Failed to open '%s' for writing\n", $file)); if (!fwrite($fp, "1;a\n") || !fwrite($fp, "2;b\n")) die(sprintf("Failed to write to '%s'\n", $file)); fclose($fp); $sql = sprintf("LOAD DATA LOCAL INFILE '%s' INTO TABLE test FIELDS TERMINATED BY ';'", $file); if (!($mysql = mysql_connect($host, $user, $pass, true, $flags))) die(sprintf("Failed to connect to MySQL\n")); printf("MySQL %s\n", mysql_get_server_info($mysql)); mysql_select_db($db); mysql_query("DROP TABLE IF EXISTS test", $mysql); mysql_query("CREATE TABLE test(id INT, col_a VARCHAR(255))", $mysql); mysql_close($mysql); if (!($mysql = mysql_connect($host, $user, $pass, true, $flags))) die(sprintf("Failed to connect to MySQL\n")); if (!mysql_db_query($db, $sql, $mysql)) die(sprintf("LOAD DATA failed: %s\n", mysql_error($mysql))); $res = mysql_query("SELECT * FROM test", $mysql); while ($row = mysql_fetch_row($res)) var_dump($row); -------- gives ------------- PHP 5.3.12-dev MySQL 5.5.16-log array(2) { [0]=> string(1) "1" [1]=> string(1) "a" } array(2) { [0]=> string(1) "2" [1]=> string(1) "b" }