我是靠谱客的博主 疯狂白云,最近开发中收集的这篇文章主要介绍r 64位连接mysql_如何将R与MySQL连接或如何安装RMySQL软件包?,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

bd96500e110b49cbb3cd949968f18be7.png

I am new in R and i am trying to connect R with MySQL. I have installed mysql-5.5.22-winx64 and R-2.12.0 for 64 bit. I have already set MYSQL_HOME environment path(C:Program FilesMySQLMySQL Server 5.5) and trying to follow these steps:

Install latest RTools from here

install MySQL or header and library files of mysql

create or edit file C:Program FilesRR-2.12.1etcRenviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files)

copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.

copy libmysql.dll to C:Program FilesRR-2.12.1bin or to windows/system32 directory.

run install.packages('RMySQL',type='source') and wait while compilation will end.

but still i am getting this error:-

*> install.packages('RMySQL',type='source')

--- Please select a CRAN mirror for use in this session ---

trying URL 'http://ftp.iitm.ac.in/cran/src/contrib/RMySQL_0.9-3.tar.gz'

Content type 'application/x-gzip' length 165363 bytes (161 Kb)

opened URL

downloaded 161 Kb

* installing *source* package 'RMySQL' ...

ERROR: configuration failed for package 'RMySQL'

* removing 'C:/PROGRA~1/R/R-212~1.0/library/RMySQL'

* restoring previous 'C:/PROGRA~1/R/R-212~1.0/library/RMySQL'

The downloaded packages are in

‘C:UserssharadAppDataLocalTempRtmpdQHwCbdownloaded_packages’

Warning message:

In install.packages("RMySQL", type = "source") :

installation of package 'RMySQL' had non-zero exit status*

Please suggest me how can I solve this problem?

Finally I got the solution:-

You can see the solution in detail on my blog.

I was working for last 2 days on Installation of R with RMySQL package, finally got the solution for that, here are the steps to install RMySQL package:-

DOWNLOAD SOFTWARE FROM THE FOLLOWING LINKS:

* a. R2.13.2: Download R from http://cran.stat.sfu.ca/index.html

b. RTools 214: Download RTools from http://cran.cict.fr

c. RMySQL 0.8-0.tar.gz: Download RMySQL from

http://biostat.mc.vanderbilt.edu/wiki/main/RMySQL/RMySQL_0.8-0.tar.gz

d. MySQL Server 5.0: download it from http://dev.mysql.com

e. RSTUDIO (optional): download it from http://rstudio.org*

SET THE FOLLOWING ENVIRONMENT VARIABLES

* a. MYSQL_HOME : /path to MySQL installation folder

e.g. MYSQL_HOME= C:Program FilesMySQLMySQL Server 5.5

b. R_HOME: /path to R installation

e.g. R_HOME=C:Program FilesRR-2.13.2

c. PATH: Modify path to accommodate the above variables. *

Be sure that the following paths areincluded in your Windows PATH variable:

Rtools2.14bin

Rtools2.14MinGWbin

Rtools2.14MinGW64bin

CREATE FOLDER AND COPY FILES

* a. OPT: Create a folder OPT under

C:Program FilesMySQLMySQL Server 5.5lib and

copy MYSQLLIB.LIB the above path.

Also copy libmysql.dll to

\RR-2.14.0bin(64 bit) Or

\RR-2.14.0bini386 (32 bit) and

to C:WindowsSystem32.

b. Renviron.site: create or edit a file

\RR-2.14.0etcRenviron.site and

add a line:

MYSQL_HOME =”C:/Program Files/MySQL/MySQL Server 5.5/”

NB: USE FORWARD SLASH AND DOUBLE QUOTES HERE

c. libMySQL.dll: Copy this file to

C:Program FilesRR-2.13.2bini386 as well as

C:Program FilesRR-2.13.2bin*

RUN COMMANDS

a. Install.Packages: Run R GUI by clicking on the R icon on desktop or from Start menu. Type

INSTALL.PACKAGES(“RMySQL”,type=”Sources”).

This will download the required software from repositories.

b. Command Prompt: Copy the downloaded zip file (in step 4.a.) and paste it under R installation folder.

Go to start menu and open Command Prompt. Go to the R installation folder and type R CMD INSTALL RMySQL_0.8-0.tar.gz

*COMMANDS:

library(RMySQL)

drv = dbDriver("MySQL")

con = dbConnect(drv,host="localhost",dbname="test",user="root",pass="root")

album = dbGetQuery(con,statement="select * from t_master")

album*

解决方案

It is not a direct answer but still you may find it helpful:

Use a more up to date version of R (currently at 2.15)

On Windows platforms I'd rather use RODBC + Windows MySQL driver, unless you are in a environment with heterogenous platforms (i.e. Linux and Windows) where code is heavily shared among team members. And even then choosing between using RMySQL and RODBC in the same script depending on the platform it runs is a simple if() {...} else {...}

Notice that I am not saying there are no success stories with what you are trying to do, but IMHO you'll be up and running sooner with the above.

最后

以上就是疯狂白云为你收集整理的r 64位连接mysql_如何将R与MySQL连接或如何安装RMySQL软件包?的全部内容,希望文章能够帮你解决r 64位连接mysql_如何将R与MySQL连接或如何安装RMySQL软件包?所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(59)

评论列表共有 0 条评论

立即
投稿
返回
顶部