## Not run:
# # Connect to a MySQL database running locally
# con <- dbConnect(RMySQL::MySQL(), dbname = "mydb")
# # Connect to a remote database with username and password
# con <- dbConnect(RMySQL::MySQL(), host = "mydb.mycompany.com",
# user = "abc", password = "def")
# # But instead of supplying the username and password in code, it's usually
# # better to set up a group in your .my.cnf (usually located in your home
# directory). Then it's less likely you'll inadvertently share them.
# con <- dbConnect(RMySQL::MySQL(), group = "test")
#
# # Always cleanup by disconnecting the database
# dbDisconnect(con)
# ## End(Not run)
# All examples use the rs-dbi group by default.
if (mysqlHasDefault()) {
con <- dbConnect(RMySQL::MySQL(), dbname = "test")
summary(con)
dbDisconnect(con)
}
Run the code above in your browser using DataLab