- Introduction
- RMySQL is a database interface and MySQL driver for R
- The latest version will always be available here: http://cran.r-project.org/web/packages/RMySQL/index.html
- Binaries No Longer Supported
- It too difficult to keep binary versions of RMySQL up to date with the latest R version and MySQL version
- Always compiling RMySQL from the latest source packages is recommended.
- Installation (officer)
- Download Rtools from here: http://www.murdoch-sutherland.com/Rtools/
- making sure to install the correct version for your R version
- Be sure that you place the Rtools bin path in your default path so that R can invoke the compilers
- Install a MySQL client library from http://www.mysql.com or http://dev.mysql.com
- If you already installed a MySQL server, you may want to re-run the install to ensure that you also installed client header and library files
- Note that Xampp doesn't include these
- Edit or create the file Renviron.site and add the variable MYSQL_HOME which contains the location of your MySQL install
- The file typically isn't created when installing R, so you may need to create it yourself
- You will want to place it under the /etc directory in your R Home area
- If you don't know where that is, you can issue R.home() at your R prompt
- You will be adding a variable named MYSQL_HOME in variable=value syntax
- Here's an example:
- Location of Renviron.site: C:/PROGRA~1/R/R-2.11~1.0/etc/Renviron.site
- Content is: MYSQL_HOME=C:/PROGRA~1/MySQL/MYSQLS~1.0/
- Restart R and execute install.packages('RMySQL',type='source') at the R prompt
- Download Rtools from here: http://www.murdoch-sutherland.com/Rtools/
- Installation (personal)
본 장에서는 Windows에서 RMySQL를 사용하여 원격 MySQL를 연동하는 방법을 설명- Windows 정보
- Windows 7
- 사전 준비
- Rtools 설치
- MySQL Server가 설치된 원격 서버
- 설명
- Connector/C (libmysqlclient) 설치
- 다음 주소에서 다운로드: http://dev.mysql.com/downloads/connector/c/
- libmysql.dll 파일 복사
- Connector/C 설치 위치가 'C:\Program Files\MySQL\MySQL Connector C 6.1' 라고 가정
- lib 폴더에 opt 폴더를 생성 (32 bit)
- lib 폴더의 libmysql.lib 를 opt 폴더로 복사 (32 bit)
- lib 폴더에서 libmysql.dll 를 bin 폴더로 복사 (64 bit)
- R 관련 설정
- R 설치 위치가 'D:\Program Files\R\R-3.1.0' 라고 가정
- etc 폴더에 Renviron.site 파일 생성
- 다음 내용 추가: MYSQL_HOME=C:/Program Files/MySQL/MySQL Connector C 6.1
- R 시작
- 다음 명령어 실행: Sys.getenv('MYSQL_HOME')
- 반환 값: C:/Program Files/MySQL/MySQL Connector C 6.1
- RMySQL 사용
- install.packages('RMySQL',type='source')
- library(RMySQL)
- con <- dbConnect ( MySQL () , user ="계정", password ="비번", dbname ="데이타베이스", host ="IP 주소")
- dbGetQuery (con , " select * from 테이블명 ")
- Connector/C (libmysqlclient) 설치
- Windows 정보
- Reference
Friday, January 2, 2015
RMySQL
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.