LoginSignup
9
10

More than 5 years have passed since last update.

RでMySQL

Last updated at Posted at 2013-12-28

必要ならsshポートフォーワーディングでトンネルをつくっておく

shell
ssh -L 3306:localhost:3306 hoge@hoge.com

RMySQLライブラリを使う。入れていなければインストール

R
install.packages("DBI")
install.packages("RMySQL")

つかってみる

R
library(RMySQL)
dbconnector <- dbConnect(MySQL(), dbname="hoge", user="hoge", password="hoge", host="127.0.0.1", port=3306)
> query.result <- dbSendQuery(dbconnector, "select * from hoge")
> test.table <- fetch(query.result)
> test.table

ハマりポイント

  • r側ではhost="localhost"ではなくhost="127.0.0.1"

追記

  • タイポを修正
  • RMySQL version 0.9-3に対応
9
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
10