如何更正 MySQL 加载错误 [英] How can I correct MySQL Load Error

查看:39
本文介绍了如何更正 MySQL 加载错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太确定我正在尝试执行以下 MySQL 程序是否关闭了与此类似的问题.

mysql -e "加载数据本地 infile \'/tmp/ept_inventory_wasp_export_04292013.csv' 到 \表 wasp_ept_inv 字段以 ',' 结尾 \以 '\n' 结尾的行;"

在 bash 命令行中出现此错误

ERROR 1148 (42000) at line 1: The used command is not allowed with this MySQL version

我该如何解决这个问题?

我实际上是从 Python 程序中运行此命令,但将命令拉出以尝试在 bash 命令行中摆弄它.

我已经看到了如何修改 my.cnf (local-infile),但是如果可以避免的话,我不希望全局更改.

这是 MySQL 版本.

mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (i686) using readline 6.2

解决方案

LOAD DATA LOCAL 的安全问题:

<块引用>

为了解决这些问题,我们改变了LOAD DATA LOCAL 从 MySQL 3.23.49 和 MySQL 4.0.2(Windows 4.0.13)开始处理:

I'm not quite sure a similar question to this was closed by I'm trying to execute the following MySQL program.

mysql -e "load data local infile \
'/tmp/ept_inventory_wasp_export_04292013.csv' into \
table wasp_ept_inv fields terminated by ',' \
lines terminated by '\n' ;"

at the bash command line and get this error

ERROR 1148 (42000) at line 1: The used command is not allowed with this MySQL version

How can I work around this problem?

I am actually running this command from a Python program, but pulled the command out to try fiddling with it at the bash command line.

I've seen how I can modify my.cnf (local-infile), but I do not want that global a change if I can avoid it.

Here's the MySQL version.

mysql Ver 14.14 Distrib 5.5.31, for debian-linux-gnu (i686) using readline 6.2

解决方案

As documented under Security Issues with LOAD DATA LOCAL:

To deal with these problems, we changed how LOAD DATA LOCAL is handled as of MySQL 3.23.49 and MySQL 4.0.2 (4.0.13 on Windows):

  • By default, all MySQL clients and libraries in binary distributions are compiled with the --enable-local-infile option, to be compatible with MySQL 3.23.48 and before.

  • If you build MySQL from source but do not invoke configure with the --enable-local-infile option, LOAD DATA LOCAL cannot be used by any client unless it is written explicitly to invoke mysql_options(... MYSQL_OPT_LOCAL_INFILE, 0). See Section 20.6.6.49, "mysql_options()".

  • You can disable all LOAD DATA LOCAL statements from the server side by starting mysqld with the --local-infile=0 option.

  • For the mysql command-line client, enable LOAD DATA LOCAL by specifying the --local-infile[=1] option, or disable it with the --local-infile=0 option. For mysqlimport, local data file loading is off by default; enable it with the --local or -L option. In any case, successful use of a local load operation requires that the server permits it.

  • If you use LOAD DATA LOCAL in Perl scripts or other programs that read the [client] group from option files, you can add the local-infile=1 option to that group. However, to keep this from causing problems for programs that do not understand local-infile, specify it using the loose- prefix:

    [client]
    loose-local-infile=1
    

  • If LOAD DATA LOCAL is disabled, either in the server or the client, a client that attempts to issue such a statement receives the following error message:

    ERROR 1148: The used command is not allowed with this MySQL version

这篇关于如何更正 MySQL 加载错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆