By ccercadoj
I want to use the new DigitalOcean MySQL Managed Databases with my PHP application but I’m getting this error here:
https://distanciauss.com/test.php
Connect Error (2003) Can’t connect to MySQL server on ‘db-mysql-aldodiego-2019-do-user-6529643-0.db.ondigitalocean.com’ (110)
already change the database password type to: mysql_native_password
I still have the same error can someone help me connect?
I am using this code
<?php
$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";
$mysqli->close();
?>
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
This comment has been deleted
Hello,
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! Regards, Bobby
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.