access remote Digitaocean databases PHP - Mysql

Posted September 26, 2019 3.6k views

I want to use the new DigitalOcean MySQL Managed Databases with my PHP application but I’m getting this error here:

Connect Error (2003) Can’t connect to MySQL server on ‘’ (110)

already change the database password type to: mysqlnativepassword

I still have the same error can someone help me connect?

I am using this code

$mysqli = new mysqli('<host>', '<user>', '<password>', '<database>');

 * This is the "official" OO way to do it,
 * BUT $connect_error was broken until PHP 5.2.9 and 5.3.0.
if ($mysqli->connect_error) {
    die('Connect Error (' . $mysqli->connect_errno . ') '
            . $mysqli->connect_error);

 * Use this instead of $connect_error if you need to ensure
 * compatibility with PHP versions prior to 5.2.9 and 5.3.0.
if (mysqli_connect_error()) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());

echo 'Success... ' . $mysqli->host_info . "\n";


These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
2 answers


I would recommend checking the following:

  • Make sure that you have specified the 25060 MySQL port in your connection string, it is not the default one so you need to specify it explicitly

  • Make sure that you have added your Droplet’s IP under the trusted sources for your Managed database

  • Make sure that the outgoing TCP traffic for port 25060 is allowed on your droplet

Hope that this helps!

  • Everything is already added, can you help me with that please

    • It sounds like that the outgoing TCP traffic for port 25060 might not be open on your droplet. To test that what you could do is:

      • SSH to your droplet

      • Then run:

      telnet 25060

      That way you would be able to test the connection.

      If this fails, I would suggest checking your firewall status:

      sudo ufw status

      Let me know how it goes!