1
我是使用Mac(OS X)的Rt和RStudio的新手。与RStudio一起使用RMySQL的SSH隧道
我成功使用sequel Pro来看这样的DB。
我使用数据库连接与RStudio RMySQL和DBI(下面的代码)。
library(DBI)
library(RMySQL)
con <- dbConnect(RMySQL::MySQL(),
username = "username",
password = "password",
host = "hostname-xxx.ap-northeast-1.rds.amazonaws.com",
port = 3306,
dbname = "dbname"
)
但我得到了以下错误。
Error in .local(drv, ...)
Failed to connect to database: Error: Access denied for user 'username'@'yyyyyyyyyyymarunouchi.tokyo.ocn.ne.jp' (using password: YES)
所以ssh这样的隧道使用终端。
ssh -f [email protected] -i ~/.ssh/ssh_key -L 3306:hostname-xxx.ap-northeast-1.rds.amazonaws.com:3306 -N
并成功登录。
之后,为了确认,在命令(终端)下执行,但在输入正确密码后失败。
mysql -h 127.0.0.1 -p -u username dbname
,错误代码
ERROR 1044 (42000): Access denied for user 'username'@'localhost' to database 'dbname'
(其它机器相同的用户名登录成功。我不知道为什么...)
和数据库连接(RMySQL与RStudio)正显示出相同以上错误。
任何相同的情况?请告诉我应该怎么做。
谢谢。
如果是数据库凭证问题,则“用户名”帐户设置为数据库应该是错误的,那么'mysql -h 127.0 ...'命令不会成功执行所有终端,或者失败所有终端? '''其他具有相同用户名的机器成功登录。我不知道为什么......''' –
'sql -h 127.0.0.1 -p password -u username dbname'在错误消失以及mysql命令在终端中成功执行。但RStudio中的dbConnect发生错误:'.local(drv,...)中的错误: 无法连接到数据库:错误:无法连接到'hostname-xxx.ap-northeast-1.rds上的MySQL服务器。 amazonaws.com'(60)' –