I am using Drupal 7.56 and CiviCRM 4.7.21 on Ubuntu 16.04. The Apache and MySQL servers run on the same host.

The Drupal and CiviCRM databases are stored on the same server, and are accessed with a single user. Drupal is happy and works just fine. But CiviCRM, using the same user as Drupal, cannot connect to the database.

The error message appears under the headings "CiviCRM Database Details" and "Drupal Database Details", in the following row:

Are the access credentials correct? | That username/password doesn't work:

Here's what I've done so far

  • I have triple checked that I am not making any typos.
  • I have verified that I can log into the MySQL account using the MySQL shell.
  • I have verified that MySQL is listening on the default port.
  • I have verified that MySQL is binding to
  • I have verified that there is no firewall in the way.
  • I have tried out opening the server to remote connections and making the MySQL user able to log in remotely. I successfully connected with Sequel Pro, but CiviCRM didn't budge. I closed things down again.

I am a loss for what else I can try. Is there something special about how CiviCRM connects to MySQL? After all, Drupal is having no problems.

I notice that the error message ends with a colon, which implies that there is supposed to be some additional information. Does this imply that there may be a bug?

Thanks very much!

  • Have you tried adding the port to the hostname even though it is default? I've run into a strange environment issue before where 'localhost' was refusing to connect, but specifying 'localhost:3306' worked (even though you shouldn't have to specify the :3306 and I think it tells you as much). Commented Jul 7, 2017 at 18:37
  • @EliLisseck That did it! Thank you so much, that's something I never would have tried on my own. You should add it as an answer to this question so I can put down that you solved it.
    – user4831
    Commented Jul 7, 2017 at 21:29
  • 1
    sounds unrelated, but flagging that seems to be discussion around problems with 4.7.21 release in terms of new installs here: chat.civicrm.org/civicrm/pl/bssib8drn3ywixkzisq9swa5mw
    – petednz - fuzion
    Commented Jul 7, 2017 at 22:22

1 Answer 1


In my experience if 'localhost' (or your host) was refusing to connect on default port with all credentials/permissions definitely correct, specifying 'localhost:3306' will work (even though you shouldn't have to specify the :3306, and I think it tells you as much).

I will also note that this is something I have only experienced recently, and with this question there are examples on Ubuntu, and in my case MAMP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.