This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Failed To Connect To The Ensembl Mysql Database

Hello

I am trying to connect to the mysql database available at ensembl in order to perform some query with the follwoing code but i Get a "Could not connect:" message so I am wondering if I failed because I am not allowed to perform connection out of my network for security reason.

So if someone has the time to test it and to connect successfully I would appreciate.

Thanks in advance.

<?php
$link = mysql_connect('ensembldb.ensembl.org:3306', 'anonymous', '');

if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
mysql_close($link);
?>
mysql ensembl

2 answers

The port is 5306 and not 3306. I had the same problem two years ago and they answered me that:

helpdesk@ensembl.org, on May 22th 2008: From release 48 onwards the Ensembl databases are on port 5306 instead of 3306 of ensembldb…

I asked them if they could update their docs but they didn't do it yet, I don't know why.

Actually it's detailed at ensembl.org/info/data/mysql.html The pre-v48 release is on 3306 and anything post is on 5306

Actually it's detailed at ensembl.org/info/data/mysql.html Version47 and prior releases are on 3306 and anything post is on 5306

Well this works for me so my guess would be you need to check your firewall settings (both outgoing and incoming http://www.ensembl.org/info/data/mysql.html )

<?php
$link = mysql_connect('ensembldb.ensembl.org:3306', 'anonymous', '');

if (!$link) {
    die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';

$db_list = mysql_list_dbs($link);

while ($row = mysql_fetch_object($db_list)) {
     echo $row-&gt;Database . "\n";
}

mysql_close($link);
?>

Also the latest db releases are on port 5306

If you have a mysql client installed this should work :- mysql -h ensembldb.ensembl.org -P 5306 -u anonymous

Log in to answer this question.