Here is my code for PHP for connecting to the database, a Cloud SQL instance for MySQL:
define('DB_SERVER', '192.0.0.1');
define('DB_USERNAME', 'username');
define('DB_PASSWORD', 'password');
define('DB_NAME', 'db');
$db = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME) or die(mysqli_connect_error());
Obviously the DB_SERVER
is not the actual IP address, nor are the credentials, but I did put in a dummy one to see if I needed to add anything like cloudsql:/
or jdbc://
like you do in Java.
I did authorize the IP address for the webserver on Cloud SQL, but all it returns is a Connection Timed Out
error; What can I do to fix this?
I'm certain that the credentials are correct, and that I can connect from other authorized IP addresses, as I have been able to access from another account & multiple IP addresses through the MySQL workbench.
mysql -u username -h 192.0.0.1 -ppassword -D db -P {YOUR SERVER PORT}
? – Karlommysql -h 192.0.0.1:3306 -u user -p db
too, just kind of hangs. Weird thing is, MySQL Workbench works fine for me. – Dragonsnap