Answers:
如果MySQL Debian-7 Minimum无法使用local_infile
,请查看用于编译的所有make文件,以查看默认情况下是否禁用了它,或者是否local_infile
为Debian-7启用了它。
在花费那种时间之前,请运行以下命令:
SHOW GLOBAL VARIABLES LIKE 'local_infile';
SET GLOBAL local_infile = 'ON';
SHOW GLOBAL VARIABLES LIKE 'local_infile';
它应回显以下内容:
mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | OFF |
+---------------+-------+
1 row in set (0.00 sec)
mysql> SET GLOBAL local_infile = 'ON';
Query OK, 0 rows affected (0.06 sec)
mysql> SHOW GLOBAL VARIABLES LIKE 'local_infile';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| local_infile | ON |
+---------------+-------+
1 row in set (0.00 sec)
mysql>
如果仍然显示'OFF'
,则在编译器设置中深入了解以启用它。
如果设置为'ON'
,则可以。
请注意,我没有说
SET GLOBAL local_infile = 1;
我说用
SET GLOBAL local_infile = 'ON';
如果在 my.cnf
[mysqld]
local_infile=ON
并且重启mysql也不起作用,您将必须使用以下方式启动mysql:
echo "SET GLOBAL local_infile = 'ON';" > /var/lib/mysql/init_file.sql
chown mysql:mysql /var/lib/mysql/init_file.sql
service mysql stop
service mysql start --init-file=/var/lib/mysql/init_file.sql
rm -f /var/lib/mysql/init_file.sql
或将其添加到 my.cnf
[mysqld]
init-file=/var/lib/mysql/init_file.sql
然后重启mysql。
试试看 !!!
$con = mysqli_init(); $con->options(MYSQLI_OPT_LOCAL_INFILE, true);
mysqli.allow_local_infile = On
对我来说是一件好事,因为GLOBAL local_infile = 'ON';
已经启用了。
local_infile | ON
。看来问题出在mysql,而不是mysqlPHP
-PHP连接器/驱动程序(mysqli)。