[问题类型]:
程式咨询(我想用R 做某件事情,但是我不知道要怎么用R 写出来)
[软件熟悉度]:
入门(写过其他程式,只是对语法不熟悉)
[问题叙述]:
OS: Debian GNU/Linux Jessie (8.0)
MySQL 版本:MariaDB 10.0.22
我想用 R 连接到 MySQL 数据库,却出现以下错误讯息:
Failed to connect to database: Error: Can't connect to local MySQL server
through socket '/tmp/mysql.sock'
已排除数据库端的问题,我自已用 MariaDB 的 jdbc driver 可以连线
另外,我在自已的系统内,找不到 mysql.sock 这个档案
要透过其他的 package 来连线?
[程式范例]:
library('RMySQL')
envValue <- Sys.getenv(c("MIRNA_DB_USERNAME", "MIRNA_DB_PASSWORD",
"MIRNA_DB", "MIRNA_DB_HOST"))
mydb <- dbConnect(RMySQL::MySQL(),
user=envValue['MIRNA_DB_USERNAME'],
password=envValue['MIRNA_DB_PASSWORD'],
dbname=envValue['MIRNA_DB'],
host=envValue['MIRNA_DB_HOST'])
[环境叙述]:
R version 3.2.2 (2015-08-14)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Debian GNU/Linux 8 (jessie)
locale:
[1] LC_CTYPE=zh_TW.UTF-8 LC_NUMERIC=C
LC_TIME=zh_TW.UTF-8
[4] LC_COLLATE=zh_TW.UTF-8 LC_MONETARY=zh_TW.UTF-8
LC_MESSAGES=zh_TW.UTF-8
[7] LC_PAPER=zh_TW.UTF-8 LC_NAME=C
LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=zh_TW.UTF-8
LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] RMySQL_0.10.7 DBI_0.3.1
loaded via a namespace (and not attached):
[1] tools_3.2.2
[关键字]:
MySQL