在mysql中启用LOAD DATA LOCAL INFILE
作者:互联网
默认情况下不启用LOAD DATA LOCAL INFILE.通常,应该通过在my.cnf中放置local-infile = 1来启用它.但它并不适用于所有安装.根据我的经验,它适用于Debian 7,但不适用于Debian 7 minimal,尽管这两个安装都来自相同的预编译deb包.两者都在OpenVZ VPS上.
如何调试local-infile = 1为什么不能用于安装,以及如何安全地激活LOAD DATA LOCAL INFILE?
解决方法:
如果MySQL Debian-7 minimal不能使用local_infile,请查看用于编译的所有make文件,以查看它是否默认禁用或者是否为Debian-7启用了local_infile.
在这段时间之前,请运行以下内容:
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';
option local_infile is Boolean, not numeric.
如果在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.
试试看 !!!
标签:linux,mysql,configuration,mysql-5-5,my-cnf 来源: https://codeday.me/bug/20190805/1593494.html