title: Golang GAE integration with Google Cloud SQL
body: <p>I'm having a lot of trouble connecting my Golang GAR to Google Cloud SQL. I'm currently using <a href="https://github.com/go-sql-driver/mysql" rel="nofollow">https://github.com/go-sql-driver/mysql</a> driver. My connection string is </p>
  
  <pre><code>db, err := sql.Open("mysql", "'root:password'@tcp(ip-address:3306)/dbname")
  </code></pre>
  
  <p>I always get 1045 error, according to Google: </p>
  
  <blockquote>
    <p>If MySQL rejects the connection, for example, because you have specified an incorrect MySQL user name or password, the error you receive will be:
    ERROR 1045 (28000): Access denied for user 'user-name'@'client-IP' (using password: YES)</p>
  </blockquote>
  
  <p>When I connect to the db via SQL command line tool with the same username and password, I get access.</p>
  
  <p>I doubled checked myself and went over all the SQL db creation steps including providing my IP address as authorized to connect the SQL db and creating user via MySQL command line.</p>
  
  <p>There might be some problem with the string of the user name and pass that I'm providing to the Go SQL driver: "'root:password'@tcp(ip-address:3306)/dbname".</p>
  
  <pre><code>import (
  
      "time"
      "net/http"
  
      "database/sql"
      _ "github.com/mysql"
  
      "appengine"
      "appengine/datastore"
      /*"appengine/user"*/
  
      "github.com/go-martini/martini"
      "github.com/codegangsta/martini-contrib/binding"
  
  )
  
  m.Get("/GetTheShop/:Bid" , func(params martini.Params,w http.ResponseWriter, r *http.Request) string{
  
              db, err := sql.Open("mysql", "cloudsql:insName*db/user/pass")
  
              if err != nil {
                  return(err.Error()+" 1") 
              }
  
              defer db.Close()
              // Open doesn't open a connection. Validate DSN data:
  
              err = db.Ping()
              if err != nil {
                  return(err.Error()+" 2") 
              }
  
              return "db connected"
  })
  </code></pre>