Question
access remote Digitaocean databases PHP - Mysql
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: mysqlnativepassword
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();
?>
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.
×