[問題類型]:
程式諮詢(我想用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