mysql版本5.5.29,是通过软件中心安装的。
刚装完时,在mysql命令行下,load data local infile时 报错信息是iThe used command is not allowed with this MySQL version
然后,将/etc/mysql/my.cnf配置文件加入--local-infile=1后,在mysql命令行下执行load data local infile 成功。
但是通过C api的mysql_query函数执行load data local infile时不成功。代码如下:
res2 = mysql_query(conn_ptr,"load data local infile \'/home/tcz/test.csv\' into table test fields terminated by \',\' lines terminated by \'\n\'") ;
fprintf(stderr,"Load error %d:%s\n",mysql_errno(conn_ptr),mysql_error(conn_ptr));用api函数mysql_errno和mysql_error打印出的错误代码如下
Load error 1148:The used command is not allowed with this MySQL version
跟当初没有配置--local-infile=1时在mysql下执行时的错误信息一样。
配置后,为何在mysql命令行下可以执行,而通过C api不能执行呢? 谢谢各位,本人刚刚学习mysql ,敬请指教。
刚装完时,在mysql命令行下,load data local infile时 报错信息是iThe used command is not allowed with this MySQL version
然后,将/etc/mysql/my.cnf配置文件加入--local-infile=1后,在mysql命令行下执行load data local infile 成功。
但是通过C api的mysql_query函数执行load data local infile时不成功。代码如下:
res2 = mysql_query(conn_ptr,"load data local infile \'/home/tcz/test.csv\' into table test fields terminated by \',\' lines terminated by \'\n\'") ;
fprintf(stderr,"Load error %d:%s\n",mysql_errno(conn_ptr),mysql_error(conn_ptr));用api函数mysql_errno和mysql_error打印出的错误代码如下
Load error 1148:The used command is not allowed with this MySQL version
跟当初没有配置--local-infile=1时在mysql下执行时的错误信息一样。
配置后,为何在mysql命令行下可以执行,而通过C api不能执行呢? 谢谢各位,本人刚刚学习mysql ,敬请指教。
error 2027:Malformed packet,网上说是残缺信息包错误,不知道这是什么意思,也没找到处理方法。继续求指教。谢谢!
res2 = mysql_query(conn_ptr,"set global LOAD DATA LOCAL =1;load data local infile \'/home/tcz/test.csv\' into table test fields terminated by \',\' lines terminated by \'\n\'") ;可能原因
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
服务端和客户端都要设置
error 1064:You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'LOAD DATA LOCAL=1;load data local infile '/home/tcz/test.csv' into table test fi' at line 1
[mysql]
[client]那么,你可以从你发起的sql语句中去掉:set global LOAD DATA LOCAL=1这一段。
在创建连接之前,调用API:
显式调用mysql_options (...MYSQL_OPT_LOCAL_INFILE,0), 具体这个常量名可能略有变化,修改一下。
然后看看是否能够了运行,
如果仍然出错,应该是mysql的源码做了手脚。