I am trying to use cloud SQL / mysql instance for my APPEngine account. The app is an python django-2.1.5 appengine app. I have created an instance of MYSQL in the google cloud.
I have added the following in my app.yaml file copied from the SQL instance details:
beta_settings:
cloud_sql_instances: <INSTANCE_CONNECTION_NAME>=tcp:<TCP_PORT>
I have given rights for my appengine project xxx-app's owner xxx-
[email protected]
theCloud SQL Client
rights. I have created a DB user account specific for the appXYZ
which can connect to all hosts (* option)My connection details in settings.py are the following:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'my-db',
'USER': 'appengine',
'PASSWORD': 'xxx',
'HOST': '111.111.11.11', # used actual ip
'PORT': '3306'
}
}
- I have also tried as per https://github.com/GoogleCloudPlatform/appengine-django-skeleton/blob/master/mysite/settings.py:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'HOST': '/cloudsql/<your-project-id>:<your-cloud-sql-instance>',
'NAME': '<your-database-name>',
'USER': 'root',
}
}
- I cannot connect from the local as well. However, if I do a
Add Network
of my local IP and then try to connect the local connects. THe app runs fine locally after adding the network of local IP Address using CIDR notation.
My problems:
- I am unable to connect to the Cloud sql without adding the AppEngine assigned IP Address. It gives me an error :
OperationalError: (2003, "Can't connect to MySQL server on '0.0.0.0' ([Errno 111] Connection refused)")
- Where can I find the appengine's assigned IP Address. I dont mind even if it is temporary. I understand if I need static IP Address I will have to create a Compute VM Instance.