Php – How to connect to Cloud SQL MySQL database from App Engine

google-app-enginegoogle-cloud-sqlPHP

I am currently setting up an open-source marketing software called Mautic on App Engine Flexible Environment. However, I'm having trouble with connecting the App Engine to the Cloud SQL MySQL database using MySQLi. Mautic is a PHP application built on top of Symfony. I tried using /cloudsql/<instance_connection_name> as the host, but it didn't work.

Does anyone have any experience with deploying Mautic on App Engine or know to address this problem?

Best Answer

Use this code to connect to your database from App Engine:

$con = mysqli_connect(null, 'root', 'password', 'db_name',null,'/cloudsql/instance_connection_name');
Related Topic