将XML导入AWS RDS实例

我正在尝试将一些xml加载到AWS RDS(mySql)实例中。

这个xml看起来像:(这是一个ISO-3661代码的xml转储)

<?xml version="1.0" encoding="UTF-8"?> <countries> <countries name="Afghanistan" alpha-2="AF" alpha-3="AFG" country-code="004" iso_3166-2="ISO 3166-2:AF" region-code="142" sub-region-code="034"/> <countries name="Åland Islands" alpha-2="AX" alpha-3="ALA" country-code="248" iso_3166-2="ISO 3166-2:AX" region-code="150" sub-region-code="154"/> <countries name="Albania" alpha-2="AL" alpha-3="ALB" country-code="008" iso_3166-2="ISO 3166-2:AL" region-code="150" sub-region-code="039"/> <countries name="Algeria" alpha-2="DZ" alpha-3="DZA" country-code="012" iso_3166-2="ISO 3166-2:DZ" region-code="002" sub-region-code="015"/> 

我正在运行的命令是:

  LOAD XML LOCAL INFILE '/var/www/ISO-3166_SMS_Country_Codes.xml' INTO TABLE `ISO-3661-codes`(`name`,`alpha-2`,`alpha-3`,`country-code`,`region-code`,`sub-region-code`); 

我得到的错误消息是:

错误1148(42000):这个MySQL版本不允许使用该命令

被引用的infile存在,我在运行命令之前select了一个数据库,并且对数据库有适当的权限。 数据库表中的列名与xml字段名完全匹配。

这里有两件事。 一个是服务器端,另一个是客户端。

在服务器(AWS RDS)上,检查您的参数组以确保local_infile设置为1 。 默认情况下,它在RDSland for 5.1和5.5中启用。

其次,假设您使用的是mysql命令行,请使用local-infile选项启动它:

 mysql --local-infile -hhostname -uusername -p databasename 

你也可以在你的my.cnf中设置local-infile,虽然在这种情况下它绑定在机器上。 YMMV,IANAL,FSCK等

注意这个5.1文档说:“默认情况下,二进制发行版中的所有MySQL客户端和库都使用–enable-local-infile选项进行编译,以便与MySQL 3.23.48和之前的版本兼容。 最近的发行版似乎并不是这样,至less:

 $ mysql --help | grep ^local-infile # Ubuntu 12.04 local-infile FALSE $ mysql --help | grep ^local-infile # Ubuntu 12.04, fairly stock AWS AMI local-infile FALSE $ mysql --help | grep ^local-infile # OSX 10.8 local-infile FALSE