简体   繁体   中英

getting error while inserting data by file in Mysql

I am trying to insert data via text file in Mysql Database and getting This error

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

 ADOConnection._Execute(LOAD DATA LOCAL INFILE '/var/www/in2fonenew/inv/test.txt'
 INTO TABLE  tbl_transaction FIELDS TERMINATED BY '||' enclosed by '`..., false)

And the Query is Mentioned Below for this Purpose

$sql="LOAD DATA LOCAL INFILE '".$docroot."/inv/".$dbfile."' INTO TABLE 
tbl_transaction FIELDS TERMINATED BY '||' enclosed by '`' LINES TERMINATED
 BY '|||||' (field1,field2,field3,field4,field5,field6)";

What i have done Wrong here?

Source: GitHub

"If LOAD DATA LOCAL INFILE 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"

LOAD DATA LOCAL INFILE must be explicitly enabled.

From the MySQL 5.5 manual page:

LOCAL works only if your server and your client both have been configured to permit it. For example, if mysqld was started with --local-infile=0, LOCAL does not work. See Section 6.1.6, “Security Issues with LOAD DATA LOCAL”.

You should set the option:

local-infile=1

into your [mysql] entry of my.cnf file or call mysql client with the --local-infile option:

mysql --local-infile -uroot -pyourpwd yourdbname

You have to be sure that the same parameter is defined into your [mysqld] section too to enable the "local infile" feature server side.

It's a security restriction.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM