I want to connect from my GAE app to my Google Cloud MySQL instance. I am using the github.com/go-sql-driver/mysql
driver and I followed the steps specified in the tutorial. Apparently I can connect to the database without an error but when I want to make a request I get driver: bad connection
and packets.go:33: unexpected EOF
. I authorised both my local IP address and the GAE app to access my database and I can connect to it from my local machine and the mysql client without a problem. I have already tried setting up my app in the standard environment and followed the advice here but it didn't work either.
That is my Go code with which I connect to the database:
host := os.Getenv("DB_HOST")
user := os.Getenv("DB_USER")
pwd := os.Getenv("DB_PWD")
connectionInfo := fmt.Sprintf("%v:%v@tcp(%v:3306)/mobile_data?parseTime=true", user, pwd, host)
db, err := sql.Open("mysql", connectionInfo)
And this is my app.yaml file:
runtime: go
vm: true
env_variables:
"DB_HOST": "[Google Cloud MySQL Instance IPv4]"
"DB_USER": "[User]"
"DB_PWD": "[Password]"
Any tip or advice is greatly appreciated!