External MySQL using Standard Environment

482 views
Skip to first unread message

Prasanga Siripala

unread,
May 23, 2016, 3:14:16 AM5/23/16
to Google App Engine
I'm trying to connect to an external MySQL database using GAE-Standard Environment (Golang).
I can't get it to work.

The documentation for GAE-Standard Environment definitely says it is possible. For obvious reasons, they are hiding how to do it!

https://cloud.google.com/appengine/docs/go/using-third-party-databases

I use Go  but also understand PHP.

my attempt:

I don't seem to be able to connect to an external MySQL database even using socket API.

Stuart Langley from GAE-PHP says it is possible: http://stackoverflow.com/questions/26322445/connecting-external-mysql-to-google-app-engine

https://github.com/go-sql-driver/mysql/issues/457

When I try to connect to an external database the 'normal way' without appengine/socket I get this error:

error: dial tcp 173.388.532.444:3306: socket: operation not permitted

When I try connecting like this (abridged):

"google.golang.org/appengine"
"github.com/go-sql-driver/mysql"
"google.golang.org/appengine/socket"

dial := func(addr string) (net.Conn, error) {
        return socket.Dial(appengine.NewContext(r), "tcp", addr)
    }

mysql.RegisterDial("external", dial)

and change my dataSourceName = something like: "id:password@external(your-amazonaws-uri.com:3306)/dbname" I get this error:

error: API error 5 (remote_socket: PERMISSION_DENIED): connection to (2, 173.388.532.444:3306,6) denied due to policy

My app is a paid google app engine-standard environment app hence sockets are available.


Adam (Cloud Platform Support)

unread,
May 24, 2016, 2:44:51 PM5/24/16
to Google App Engine
Can you share the real IP you are trying to connect to?

Prasanga Siripala

unread,
May 24, 2016, 8:14:02 PM5/24/16
to Google App Engine
What is your email address?

Prasanga Siripala

unread,
Jun 29, 2016, 12:44:30 AM6/29/16
to Google App Engine

Prasanga Siripala

unread,
Oct 7, 2016, 8:39:40 AM10/7/16
to Google App Engine

Here is my attempt to try and escape CloudSQL:

https://github.com/pjebs/GAE-Toolkit-Go/tree/master/sql




On Monday, May 23, 2016 at 5:14:16 PM UTC+10, Prasanga Siripala wrote:
Reply all
Reply to author
Forward
0 new messages