![](/img/trans.png)
[英]I got ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) with the command sudo mysql on ubuntu
[英]Access denied for user: (using password: NO) when running sqldf command — R 3.2.1, Ubuntu 14.04
我試圖在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;
我弄清楚發生了什么,下面是我的原始代碼:
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庫,一切正常!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.