I have a NodeJS app with MySQL that works locally, but now I have deployed it in APP Engine and I need to connect it with MySQL Google Cloud, I have created the MySQL instance and the database but I can't connect my app (NodeJS in App Engine) with my database in MySQL cloud, I am using the following code:
const mysql = require('mysql');
var con = mysql.createConnection({
host: "host-IP",
socketPath: "/cloudsql/project:region:instance",
user: "USERNAME",
password: "USERPASSWORD"
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
module.exports = con;
Archivo .YAML---------------------------
runtime: nodejs
env: flex
env_variables:
SQL_USER: "USERNAME"
SQL_PASSWORD: "USERPASSWORD"
SQL_DATABASE: "DBNAME"
INSTANCE_CONNECTION_NAME: "project:region:instance"
beta_settings:
cloud_sql_instances: "project:region:instance"
Please help me.