Sachin Kumar
Sachin Kumar

Reputation: 781

Unable to connect MySQL using R

I'm learning R language. I want to establish a connection with MySQL using R. I've studied how to do from here, here, tutorial and from many other websites. I've followed all the steps to connect with MySQL, but still I'm unable to connect with MySQL, and getting an error:

  Error in .local(drv, ...) : 
  Failed to connect to database: Error: Can't connect to MySQL server on 'localhost' (0)  

Here is screenshot of what I did: work done and error

I'm using R version-3.2.2 and MySQL version-5.6 and MySQL database is running on localhost:1527. Please help me to remove the error and tell me what I'm doing wrong.

INFO: I'm able to connect above MySQL database with java.

Upvotes: 3

Views: 1146

Answers (1)

anders
anders

Reputation: 824

you say that your mysql is running on localhost:1527 - but you don't specify that port in dbConnect, then it probably uses the default port, 3306, so it should not be able to connect... add the port argument to your dbConnect

dbConnect(MySQL(), user="user", password="password", dbname="dbname", host="localhost", port="1527")

Upvotes: 2

Related Questions