RMySQL dbConnect() RStudio crashes

I am using the following code to connect to a remote MySQL Database. The dbConnect function with con1 runs OK. I can access MySQL and read a table.

When I use con2 there seems to be a connection (at least I do not get an error or warning and after running the disconnect statement the result is TRUE), but when I try to read a table I get:

Error in .local(conn, statement, ...) : 
  could not run statement: No database selected

Anyone any idea why? The code:


con1 <- dbConnect(RMySQL::MySQL(), 
                  username = "public1",
                  password = "test",
                  host = "",
                  port = 3306,
                  dbname = "bitnami_moodle"

mycnf <- file.path("c:","Users","NB","my.cnf")

con2 <- dbConnect(RMySQL::MySQL(), default.file = mycnf, group = "client")

dbReadTable(conn = con, name = "mdl_user")


The content of my.cnf is:

user = public1
password = test
host =
port = 3306
dbname = bitnami_moodle

Source: mysql

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.