红联Linux门户
Linux帮助

perl DBI 连接mysql出错

发布时间:2012-04-05 10:41:21来源:红联作者:
在windows xp操作系统上安装了wampserver,其中的mysql版本是5.5.16。active perl 版本是5.14.2.1402。用ppm安装了DBI和DBD::mysql。
可以通过mysql控制台登录数据库。但用DBI连接数据库出错。

代码很简单:
#!perl -w
use DBI;
my $dbh = DBI->connect("DBI:mysql:database=transcription_factors;host=localhost","root","");

if (! defined($dbh) )
{
print "Error was:\n";
print "$DBI::errstr\n"; # $DBI::errstr is the error
# received from the SQL server
}
else
{
print "connecting to the mysql server successfully!\n";
}


报错信息:
DBI connect ('database=transcription_factors;host=localhost','root',...) failed:can't connect to MySQL server on 'localhost'(10061) at testtest.pl line 4.
为排除DBI没问题,用DBI连接sqlserver2005,可以连接成功。
请各位帮忙!
文章评论

共有 0 条评论