我正在尝试在Rstudio中运行R中的sqldf。但是,即使给出了密码,它也会产生错误,要求输入密码(如方框1所示)。
通过在终端输入mysql -u scottyiu -p
然后输入密码,我确保密码正常。它很成功,我可以进入mysql。我被困住了,真的很感激一些帮助。
专栏1:
> sqldf("select pwgtp1 from acs where AGEP < 50", password="My password", host = "localhost")
Error in mysqlNewConnection(drv, ...) :
RS-DBI driver: (Failed to connect to database: Error: Access denied for user 'scottyiu'@'localhost' (using password: NO))
Error in !dbPreExists : invalid argument type
专栏2:
mysql -u scottyiu -p
mysql> CREATE USER 'scottyiu'@'localhost' IDENTIFIED BY 'my password';
mysql> GRANT ALL PRIVILEGES ON * . * TO 'scottyiu'@'localhost';
mysql> FLUSH PRIVILEGES;
答案 0 :(得分:-1)
我知道发生了什么,下面是我原来的代码:
library(RMySQL)
library(sqldf)
fileURL <- "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2Fss06pid.csv"
download.file(fileURL,destfile="assignment2_q2.csv",method="curl")
acs <- read.csv("assignment2_q2.csv")
sqldf("select * from acs")
事实证明,RMySQL和sqldf都无法同时被调用。如果我注释掉RMySQL库,一切正常!