I want to connect to my enterprise MySQL server (APS) from RStudio local IDE.
However, I keep getting the following error message :
Error in .local(drv, ...) : Failed to connect to database: Error: Unknown MySQL Server Host '' (11001)
I installed and loaded "RMySQL","DBI" and "dbConnect" packages and using the following code (sanitized):
drv <- dbDriver("MySQL")
dbname <- "DCA-APS-PRD"
user <- "<My_SSO_USERID>"
password <- "<My_SSO_PASSWORD>"
host <- "<prod server ip>"
port <- <prod server port>
con <- dbConnect(drv, user=user, password=password, dbname=dbname, host=host, port=port)
What am I doing wrong?
First install the Connector/ODBC on your laptop, you can find it here: https://dev.mysql.com/downloads/connector/odbc/
Then insert your connection parameters (User, IP, ...) in the connector and test it using the test button. If everything is ok, install the package RODBC in R: https://cran.r-project.org/web/packages/RODBC/index.html
After that, test the connection, like this:
channel <- odbcConnect("connector", uid="user")
result <- paste("select * from table")
table<-sqlQuery(channel, result,error=TRUE)
table
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.