Sharedobe
Sharedobe

Reputation: 145

How to require SSL in RMySQL in R?

I used to connect to MySQL databases from R with this function:

db <- DBI::dbConnect(RMySQL::MySQL(),
                            user = server$db_user,
                            password = server$db_pw,
                            host = server$host,
                            dbname = db_name)

This function works perfectly fine before. Now after we modified the databases with SSL, it is no longer working. What would be the solution to there?

Upvotes: 1

Views: 1437

Answers (1)

robin loche
robin loche

Reputation: 276

I dig out this one because I spent way too much time finding the answer to this question, so I put it here (first response I stumble across during my search) for anyone else in the same case in the futur:

Just add client.flag = RMySQL::CLIENT_SSL in dbConnect to activate the SSL for the connection :

con <- dbConnect(
  RMySQL::MySQL(), 
  dbname = "my_db",
  username = user,
  password = password,
  host = host,
  client.flag = RMySQL::CLIENT_SSL
)

I couldn't find any documentation on this anywhere, the flags are not documented at all...

Upvotes: 0

Related Questions