我正在从移动RSQLite到RMySQL,我被迷惑user和password领域.FWIW,我正在运行Windows 7,R 2.12.2,MySQL 5.5(全部64位)和RMySQL 0.7-5.
我RMySQL按照之前的SO问题安装,据我所知,它可以工作(即,我可以加载包library(RMySQL)).但是当我尝试从R数据导入指南运行教程时,我收到"无法连接到数据库..."错误.这是指南教程中的代码:
library(RMySQL) # will load DBI as well
## open a connection to a MySQL database
con <- dbConnect(dbDriver("MySQL"), user = "root", password = "root", dbname = "pookas")
## list the tables in the database
dbListTables(con)
## load a data frame into the database, deleting any existing copy
data(USArrests)
dbWriteTable(con, "arrests", USArrests, overwrite = TRUE)
dbListTables(con)
## get the whole table
dbReadTable(con, "arrests")
## Select from the loaded table
dbGetQuery(con, paste("select row_names, Murder from arrests",
"where Rape > 30 order by Murder"))
dbRemoveTable(con, "arrests")
dbDisconnect(con)
Run Code Online (Sandbox Code Playgroud)
在第二行,我收到以下错误:
> con <- dbConnect(dbDriver("MySQL"), user = "richard", password = "root", dbname = "pookas")
Error in mysqlNewConnection(drv, ...) :
RS-DBI driver: (Failed to connect to database: Error: Access denied for user 'richard'@'localhost' (using password: NO)
)
Run Code Online (Sandbox Code Playgroud)
我曾尝试使用和不使用user和password管理员user.我也尝试使用dbname我之前使用命令行创建的,并使用不存在的.
有小费吗?这里有好的参考吗?谢谢!