无法连接数据库

无法连接数据库

我用perl连接ensembl数据库,在ensembl的网站上,介绍了链接的用户名是匿名登录,网站上是这样描述的:

Almost every Ensembl script that you will write will contain a use statement like the following:

use Bio::EnsEMBL::Registry;

my $registry = 'Bio::EnsEMBL::Registry';

$registry->load_registry_from_db(
    -host => 'ensembldb.ensembl.org',
    -user => 'anonymous');

我写的程序是这样的:
use DBI;
my $dbh = DBI->connect("DBI:mysql:database=Bio::EnsEMBL::Registry;host=ensembldb.ensembl.org","anonymous","anonymous", {'RaiseError' => 1});

但是始终连接不上该数据库,报错的内容如下:
DBI connect('database=Bio::EnsEMBL::Registry;host=ensembldb.ensembl.org','anonymous',...) failed: Access denied for user 'anonymous'@'222.66.**.**' (using password: YES) at C:/Users/Administrator/workspace/ConDataSet/conDB.pl line 2

请大家帮忙看看,到底是哪里出错了?

支持高科技, 虽然俺不懂BIO,

貌似不需要密码,
mysql -uanonymous -h ensembldb.ensembl.org
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 216913
Server version: 4.1.20-standard-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>


所以DBI->connect里不要写密码
感谢关注,我试了你的建议,没有用密码,
use DBI;
my $dbh = DBI->connect("DBI:mysql:database=Bio::EnsEMBL::Registry;host=ensembldb.ensembl.org","anonymous");

仍然报错,DBI connect('database=Bio::EnsEMBL::Registry;host=ensembldb.ensembl.org','anonymous',...) failed: Access denied for user 'anonymous'@'%' to database 'Bio' at C:/Users/Administrator/workspace/ConDataSet/conDB.pl line 2
anonymous的密码有时候会等於Email...
你可以试试看随便给个Email..
你应该有连上..只是没办法登入..应该是帐号密码不对...
楼主的数据名字用错了,

my $dbh = DBI->connect("DBI:mysql:database=master_schema_34;host=ensembldb.ensembl.org","anonymous");

这个是可以的,但是你可千万别照着用啊,我只是随便在里面找了个数据库名,连了一下 -_-

[Copy to clipboard] [ - ]
CODE:
#!/usr/bin/perl


use DBI;
my $dbh = DBI->connect("DBI:mysql:database=master_schema_34;host=ensembldb.ensembl.org","anonymous");

my $sth=$dbh->prepare("show tables");

$sth->execute;

my $r = $sth->fetchall_arrayref;

for (@$r) {
    print $_->[0], "\n";
}

$sth->finish;

#perl bio.pl

affy_array
affy_feature
affy_probe
alt_allele
analysis
analysis_description
assembly
assembly_exception
attrib_type
coord_system
density_feature
density_type
dna
dna_align_feature
dnac
exon
exon_stable_id
exon_transcript
external_db
external_synonym
gene
gene_archive
gene_stable_id
go_xref
identity_xref
interpro
karyotype
map
mapping_session
marker
marker_feature
marker_map_location
marker_synonym
meta
meta_coord
misc_attrib
misc_feature
misc_feature_misc_set
misc_set
object_xref
peptide_archive
prediction_exon
prediction_transcript
protein_align_feature
protein_feature
qtl
qtl_feature
qtl_synonym
regulatory_factor
regulatory_factor_coding
regulatory_feature
regulatory_feature_object
repeat_consensus
repeat_feature
seq_region
seq_region_attrib
simple_feature
stable_id_event
supporting_feature
transcript
transcript_attrib
transcript_stable_id
transcript_supporting_feature
translation
translation_attrib
translation_stable_id
xref

……,是这样啊~
那我这里的数据库的名字基本都是Bio::EnsEMBL::Registry这样的形式的,和你提供的还是有很大差别的,我该如何是好啊?

建议你用他封装好的api
非常感谢你的热心帮助,我才开始学perl,并且是在Windows下编译运行,像你说的用该网站封装好的api的话,我该怎么用呢?
用封装好的API吧,Bio::EnsEMBL::Registry里面有几十个DBConnection,自己一个个来还是挺痛苦的

请参考:
http://wiki.perlchina.org/index. ... I%E7%AE%80%E4%BB%8B

http://wiki.perlchina.org/index. ... 4%B8%8A%E7%9A%84SNP