简体   繁体   English

Perl中的MySQL错误(错误代码2)

[英]MySQL error in Perl ( Errorcode 2)

I am complete newbie in Perl. 我是Perl的新手。 I have this little sub 我有这个小子

sub processOpen{
    my($filename, $mdbh)=@_;
    my($qr, $query);

    # parse filename to get the date extension only
    # we will import the data into the table with this extension
    # /home//logs/open.v7.20120710_2213.log
    my(@fileparts) = split(/\./, $filename);
    my(@filedateparts) = split(/_/, $fileparts[2]);
    my($tableext) = $filedateparts[0];


    $query = "LOAD DATA INFILE '" . $filename . "' INTO TABLE open_" . $tableext . " FIELDS TERMINATED BY '||' LINES TERMINATED BY '\n'
              (open_datetime, open_date, period,tag_id)";

    $qr = $$mdbh->prepare($query);
    $qr->execute(); # causes error (see below)
    $qr->finish();
}

And I'm getting the following error: 我收到以下错误:

DBD::mysql::st execute failed: Can't get stat of '/home/logs/open..v7.20120710_2213.log' (Errcode: 2) at /home/thisfile.pm line 32.

Line 32 is the $qr->execute(); 第32行是$qr->execute();

Error Code 2 is most likely "File not found". 错误代码2很可能是“找不到文件”。

Does your file exist? 您的档案存在吗? Note that if you are running the perl on a separate host from the MySQL database, the file must be on the database host, not the client host. 请注意,如果在与MySQL数据库不同的主机上运行perl,则该文件必须位于数据库主机上,而不是客户端主机上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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