2016-08-14 44 views
0

我嘗試的R中Rstudio運行sqldf:(NO使用密碼)。然而,它產生的誤差,要求即使當被賦予了密碼的密碼(在框1中示出)。訪問被拒絕的用戶:運行sqldf命令時 - R的3.2.1,Ubuntu的14.04

我確信,我的密碼是通過鍵入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; 

回答

-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庫,一切正常!

+0

RMySQL和sqldf一起做工作,但你必須設置MySQL作爲解釋'?sqldf'你可以做的另一件事是強制sqldf使用DRV =參數或作爲?sqldf解釋選擇使用SQLite。 –

相關問題