首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >无法在R中通过SSH连接到MySQL服务器

无法在R中通过SSH连接到MySQL服务器
EN

Stack Overflow用户
提问于 2018-03-13 21:52:43
回答 2查看 1.2K关注 0票数 1

背景

我正在尝试从云MySQL服务器中提取数据。我刚刚将数据库从一个共享服务器移动到一个专用的云服务器。在原来的位置上一切正常。新位置需要SSH隧道。

研究/信息:

我发现的唯一相似之处就是this SO article。它实际上并不适用,因为我从未使用过localhost。

I可以在Sequel Pro和MySQL Workbench中使用相同的凭据成功连接,但我无法让R脚本发挥作用。

I可以在命令行中连接到mysql。

I do not已经在本地安装了mysql。(除非它与High Sierra一起发货;我不知道。在任何情况下,如果有本地MySQL实例,它都不会运行。)

代码:

以下是失败的地方:

代码语言:javascript
复制
con <- dbConnect(RMariaDB::MariaDB(),
                 user = 'soundings_app',
                 password = keyringr::decrypt_kc_pw("Soundings_app"),
                 host = '127.0.0.1',
                 port = 3306,
                 dbname='UFO')

我还尝试使用实际密码作为字符串,并得到相同的错误。

错误消息

代码语言:javascript
复制
Error in connection_create(host, username, password, dbname, as.integer(port),  : 
  Failed to connect: Can't connect to MySQL server on '127.0.0.1' (57)

我唯一的猜测

我能想到的唯一一件事是,SequelPro和工作台都有一个地方来输入我的私钥(~/.ssh)的位置。

你能解释一下我做错了什么吗?

更新

我将主机添加到我的./ssh/config文件中,如下所示:

代码语言:javascript
复制
Host XXX.XXX.130.0
  LocalForward 3306 localhost:3306

这导致我的其他连接失败,所以我删除了它。但是Sequel Pro在我尝试连接仍然存在的~/.ssh/config时,给了我以下信息:

代码语言:javascript
复制
Used command:  /usr/bin/ssh -v -N -S none -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -o NumberOfPasswordPrompts=3 -i /Users/steves2018air/.ssh/id_rsa -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 ubuntu@XXX.XXX.130.0 -L 49700:127.0.0.1:3306

OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/steves2018air/.ssh/config
debug1: /Users/steves2018air/.ssh/config line 1: Applying options for XXX.XXX.130.0
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Control socket " none" does not exist
debug1: Connecting to XXX.XXX.130.0 [XXX.XXX.130.0] port 22.
debug1: fd 3 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /Users/steves2018air/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /Users/steves2018air/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.4
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to XXX.XXX.130.0:22 as 'ubuntu'

更新II

一时兴起,我尝试将host从'127.0.0.1‘更改为'localhost',只是想看看会发生什么,以及这是否会带来一些启示。略有不同的错误:

代码语言:javascript
复制
Error in connection_create(host, username, password, dbname, as.integer(port),  : 
  Failed to connect: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

仍然没有解决方案或解释-你能帮上忙吗?

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49257988

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档