我正在从RSQLite
to RMySQL
我很困惑user
and 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)
在第二行我收到以下错误:
> 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)
)
我尝试过有和没有user
and password
并以管理员身份user
。我也尝试过使用dbname
我之前用命令行和不存在的命令行制作的。
有小费吗?这里有好的参考吗?谢谢!