I'm trying to connect my go app on my VM (Debain 9) server to my mysql database using the package: github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql
Looking at connection function:
// Cfg returns the effective *mysql.Config to represent connectivity to the
// provided instance via the given user and password. The config can be
// modified and passed to DialCfg to connect. If you don't modify the returned
// config before dialing, consider using Dial or DialPassword.
func Cfg(instance, user, password string) *mysql.Config {
I assume I put in the instance 'Instance connection name that is found on the GCP instance connection database page: ` package main
import (
"fmt"
"os"
"github.com/GoogleCloudPlatform/cloudsql-proxy/proxy/dialers/mysql"
)
func main() {
cfg := mysql.Cfg("MyAccount:us-west2:myDatabase", "root", os.Getenv("GCPDBPass"))
db, err := mysql.DialCfg(cfg)
if err != nil {
panic(err)
}
fmt.Print(db)
}
Where I find my instance connection name
I get an error: panic: ensure that the account has access to "MyAccount" (and make sure there's no typo in that name)
I've hooked up the VM instance IP to the Authorized networks in the Database so I don't know if I'm using the correct instance or user with this package.