1

I'm trying to connect to a MySql db on a remote machine via R, I've tried RODBC and it fails, I've tried RJDBC and it fails :

library(RJDBC)
msDriver <- JDBC(driverClass="com.mysql.jdbc.Driver", classPath=".../mysql-connector-java-5.1.13-bin.jar")
msCon <- dbConnect(msDriver, "jdbc:mysql://[IP]:5433/[SchemaName]",uid="johnDoe",pwd="word")

The message I get is :

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

I am able to connect to other DBs but MySQL seems to have different problems, has any1 succeded in doing this from R?

2 Answers2

0

Either your URL is incorrect or you have not been GRANTed permission to connect from that IP address.

The default MySQL port is 3306. I'll assume that you're certain that it's been changed for your database.

Is there a firewall between your machine and that database? If yes, is there a rule that allows your IP to pass through that port? If not, you'll need to add one.

Can you connect from that IP using the mysqladmin tool? If not, Java will have an issue, too.

I'd recommend speaking to the owner of the database to make sure that your R application has access.

duffymo
  • 305,152
  • 44
  • 369
  • 561
0

The msDriver part looks good, but I'm not certain about the uid and pwd options you're passing to dbConnect, I'd change that to user and password.

If that doesn't work I'd verify the connection to the server, try a telnet [IP] [PORT] from the machine you're using R. If it doesn't connect then the problem is with your network setup. Try checking firewall rules and proxies, if there's one.

blmayer
  • 300
  • 4
  • 15