title: Connect to Google SQL Cloud 2nd generation with Go on AppEngine
body: <p>I've seen other posts with the same issue here however none of the answers could help in my case. I have a Google SQLCloud 2nd generation database which I'm trying to make my Go Appengine app establish a connection to.
  I'm using <a href="https://github.com/go-sql-driver/mysql" rel="nofollow noreferrer">go-sql-driver/mysql</a></p>
  
  <p>At first I tried to connect the same way I used with the 1st generation just passing the project and instance names as parameters:</p>
  
  <pre><code>sql.Open("mysql", "root@cloudsql(project:instance)/database"
  </code></pre>
  
  <p>Then I've noticed from the Cloud Console and also from <a href="https://stackoverflow.com/questions/38956385/google-app-engine-golang-driver-bad-connection">this post</a> that the region is also required so my connection parameters now look like: </p>
  
  <pre><code>sql.Open("mysql", "root@cloudsql(project:uscentral1:instance)/database"
  </code></pre>
  
  <p>and also with password</p>
  
  <pre><code>sql.Open("mysql", "root:password@cloudsql(project:uscentral1:instance)/database"
  </code></pre>
  
  <p>Still not working</p>
  
  <p>My last attempt was to connect using SSL as described on <a href="https://stackoverflow.com/questions/37259595/cannot-connect-to-google-cloud-sql-using-ssl-golang-from-google-app-engine">this post</a> using the code provided from the drivers documentation: </p>
  
  <pre><code>    rootCertPool := x509.NewCertPool()
      pem, err := ioutil.ReadFile("/path/ca-cert.pem")
      if err != nil {
          log.Fatal(err)
      }
      if ok := rootCertPool.AppendCertsFromPEM(pem); !ok {
          log.Fatal("Failed to append PEM.")
      }
      clientCert := make([]tls.Certificate, 0, 1)
      certs, err := tls.LoadX509KeyPair("/path/client-cert.pem", "/path/client-key.pem")
      if err != nil {
          log.Fatal(err)
      }
      clientCert = append(clientCert, certs)
      mysql.RegisterTLSConfig("custom", &amp;tls.Config{
          RootCAs: rootCertPool,
          Certificates: clientCert,
      })
      sql.Open("mysql","root:password@cloudsql(project:uscentral1:instance)/database?tls=custom")
  </code></pre>
  
  <p>Also no luck.</p>
  
  <p>At this point I'm just running out of ideas in what the issue could be. Has anyone done anything different than what most people did in order to get it working? At this point I'm not sure if the issue is with my code, with the driver or some configuration in the CloudSQL database.</p>