Vishnu VM
Vishnu VM

Reputation: 3

RMysQL Error On linux based machine

I have a database table- db.tbl. I have isntalled R on CentOS 7.0 version. I have installed the following packages

 dbname='db'
 table='table'
 username='username'
  password='userpass'
  hostname='1.1.1.111'
  port=0000

I have written the following code to connect with mysql

require(rmysql)
conn <- dbConnect(MySQL(), username, userpass, hostname1, port=0000)

I am getting this error

Error in MySQL() : could not find function "MySQL"

I have tried:

 conn<-dbConnect("MySQL", username, userpass, hostname1, port=0000)

 Error in (function (classes, fdef, mtable)  : 
 unable to find an inherited method for function ‘dbConnect’ for signature 
 ‘"character"

Upvotes: 0

Views: 60

Answers (1)

Suanbit
Suanbit

Reputation: 491

I think you are missing the data base name

library(RMySQL)

conn <- dbConnect(MySQL(), user='username', 
              password='password', 
              dbname='database_name')

Once you are connected you can send queries to Mysql like:

dbWriteTable(conn, name='mtcars', value=mtcars.df, overwrite = T)

If doesn't work try re-installing the RMySQL package. Hope it helped :)

Upvotes: 1

Related Questions