【问题标题】:load local infile not allowed perl mysql加载本地 infile 不允许 perl mysql
【发布时间】:2012-10-20 17:46:39
【问题描述】:

谁知道如何在 Ubuntu 上的最新 MySQL 中开启加载本地 infile 设置?我编辑了/etc/mysql/my.cnf 文件并添加了

local-infile=1

在 Perl 代码中

dbConnectString=dbi:mysql:orthomcl:mysqllocalinfile=1

但仍然得到

DBD::mysql::st execute failed: The used command is not allowed with this MySQL version...

它被一个名为 OrthoMCL 的应用程序使用

我尝试配置my.cnf文件:

sudo vim /etc/mysql/my.cnf

[mysqld]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
port            = 3306
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
local-infile = 1
[mysql]
#no-auto-rehash # faster start of mysql but no tab completition
local-infile = 1

然后重启mysql服务器:

sudo service mysql restart
mysql stop/waiting
mysql start/running, process 9563

但我仍然得到:

DBD::mysql::st execute failed: The used command is not allowed with this MySQL version at ../Apps/orthomclSoftware-v2.0.3/bin/orthomclLoadBlast line 39, <F> line 12.
The used command is not allowed with this MySQL version at ../Apps/orthomclSoftware-v2.0.3/bin/orthomclLoadBlast line 39, <F> line 12.`

第 39 行是:

$stmt->execute() or die DBI::errstr;

执行上面的行:

my $sql = "
LOAD DATA
LOCAL INFILE \"$blastFile\"
REPLACE INTO TABLE $sst
FIELDS TERMINATED BY '\\t'
";
my $stmt = $dbh->prepare($sql) or die DBI::errstr;

【问题讨论】:

  • Set Load Infile更新面临的问题@Jasper
  • 我在上面更新了我的帖子,并提到我确实以多种方式尝试过该帖子,但似乎都没有效果。
  • 你的dbConnectString 对我来说有一种奇怪的格式。应该是dbi:DriverName:database_name
  • 将其更改为 dbConnectString=dbi:mysql:orthomcl 但没有成功。
  • 请尝试使用mysqlimport 命令

标签: mysql perl


【解决方案1】:
dbConnectString=dbi:mysql:orthomcl:mysql_local_infile=1:localhost:3306

我也在mysql.cnf中添加了 下

[client]
      loose-local-infile=1

为我工作

【讨论】:

  • 也解决了我的 orthoMCL 问题。谢谢。
  • 将 mysql_local_infile=1 添加到 DBI DSN 就足够了。
猜你喜欢
  • 1970-01-01
  • 2011-05-25
  • 2016-10-08
  • 2016-11-04
  • 2012-10-26
  • 1970-01-01
  • 2015-03-27
相关资源
最近更新 更多