Can not connect to local MySQL server thru Apps Script (JDBC)

Viewed 3712

Please see edits below, I'm leaving the original question to help others.

I am attempting to connect to a local MySQL server thru Apps Script and JDBC, but I keep getting one of two errors. This code:

function connectTest() {
  var conn = Jdbc.getConnection("jdbc:mysql://localhost", "root", "xxx");
}

Gives an error of Failed to establish a database connection. Check connection string, username and password.

This code:

function connectTest() {
  var conn = Jdbc.getConnection("jdbc:mysql://localhost:3306", "xxx", "pass");
}

Gives an error of Invalid argument: url.

I've tried dozens of combinations and can't get it to work. The attempts to log in from Apps Scripts do not show on the access log for MySQL (i.e. if I try to log on locally with the wrong info, I see [Note] Access denied for user 'host'@'localhost' (using password: YES). I've granted the appropriate access rights to root:

mysql> show grants for 'root'@'%';
+-------------------------------------------------------------+
| Grants for root@%                                           |
+-------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION |
+-------------------------------------------------------------+
1 row in set (0.00 sec)

Do I have to do something else to expose the local DB to the internet / Google Apps Script?

EDIT:

I'm now able to get an access denied note from MySQL log (e.g. Access denied for user 'root'@'12.123.12.123' (using password: YES)), but the app still can't connect. I tried adding bind-address with my public IP, but MySQL won't start, I get ([ERROR] Can't start server: Bind on TCP/IP port: Can't assign requested address)

function connectTest() {
  var conn = Jdbc.getConnection("jdbc:mysql://12.123.12.123:3306", "root", "xxx");
}

EDIT2: I changed bind-address=0.0.0.0 and that does allow me to get denied access errors in the DB log, but still no luck connecting. I've successfully connected to other open MySQL DB's on the internet (e.g. ensembldb.ensembl.org:3306), but I still can't connect to my local DB.

1 Answers
Related