Luckily, since you are working with an open source project, you have in your hands some capabilities to debug. I had your exact same error (at least the message), so I decided to do some debugging. Here are the steps you can try:
1. With the exact same information, can you connect to the DB with another type of client? I use the free DBVisualizer
2. On the same machine, write a small sample PHP file that tries to connect to the database. Your file could look like this:
<?PHP
$user_name = "mysql-user";
$password = "mysql-password";
$database = "mysql-db";
$server = "hostname";
$link = mysql_connect($server, $user_name, $password);
if ($link) {
$db_found=mysql_select_db($database);
if ($db_found) {
print "Database Found "
print "Connection to the Server opened"
mysql_close();
}
else {
print "Database NOT Found ";
print mysql_error();
}
}
else {
print "Could not connect to server ";
print mysql_error();
}
?>
3. Using this same test PHP file, can you connect to the MySQL database on a different server?
Using this method of debugging, you'll probably get a bit more information. Performing this, these were some of the problems I ran into:
- I needed the MySQL plugin for PHP installed (this is done with sudo yum install php-mysqli on CentOS or RedHat based distros, or sudo apt-get install php5-mysql on Ubuntu).
- I needed to set the bind-address attribute in the MySQL host's /etc/my.cnf (ex. bind-address=127.0.0.1)
- Use a tool like PHP MyAdmin to try connecting to the same database. Try it from different hosts as well.
- For some reason (I haven't been able to figure it out yet, but it's a workaround), I could not run question2answer on the same host as the one I was running MySQL on. I was fortunate to have two VM's, which are set up nearly identically, so on one VM, I have the MySQL server running, and on the other VM, I have question2answer/PHP/Linux/Apache installed, and I was able to connect to the database running on the first VM host.