-5

Possible Duplicate:
adding RMySQL package to R fails?

I have R installed on two machines running Windows 7 x64 and Cent Os x64. I am having hard time installing a package to connect to my mysql database. Database is on the Cent OS box but I can not connect to it on either machines. Both of them have R Studio installed.

The R book I have suggests installing RMySQL package but when I try to install it, it spits out the same error on both machines.

package 'RMySQL' is not available (for R version 2.15.0)

How can I fix this?


Update:

I tried running install.packages('RMySQL',type='source') which worked in my linux box but it spits out in both console and in rstudio the same message below for my windows machine.

> install.packages('RMySQL',type='source')
Installing package(s) into 'C:/Users/user/Documents/R/win-library/2.15'
(as 'lib' is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'http://ftp.osuosl.org/pub/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' ...
** package 'RMySQL' successfully unpacked and MD5 sums checked
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/Users/user/Documents/R/win-library/2.15/RMySQL'

The downloaded source packages are in
    'C:\Users\user\AppData\Local\Temp\RtmpsRHukJ\downloaded_packages'
Warning message:
In install.packages("RMySQL", type = "source") :
  installation of package 'RMySQL' had non-zero exit status

Update 2:

I've set my path variable etc in windows so I can try it via cmd. Here is the output from cmd.

* installing to library 'C:/Users/user/Documents/R/win-library/2.15'
* installing *source* package "RMySQL" ...
** package 'RMySQL' successfully unpacked and MD5 sums are checked
ERROR: configuration failed for package 'RMySQL'
* removing ... 
Community
  • 1
  • 1
ODelibalta
  • 2,194
  • 1
  • 18
  • 28
  • 3
    I'm tempted to give you -1 for not reading the package info at http://cran.r-project.org/web/packages/RMySQL/index.html which has a link to package installation instructions at http://cran.r-project.org/web/packages/RMySQL/INSTALL – Andrie Jul 04 '12 at 14:52
  • Hey Chief, you can give me what you want to keep your conscious clean. If that had worked, I would not have asked it here. Thanks – ODelibalta Jul 04 '12 at 15:41
  • 2
    Then at least give a full description of what you have tried. We can't read your mind, you know. – Andrie Jul 04 '12 at 15:46
  • I tried those steps listed for windows. Installed everything mysql related. Set my home variable etc. It appears that the version is problem but it should not be. I mean does not make sense to not have it working because it is 2.15. – ODelibalta Jul 04 '12 at 15:50
  • What part of "I have a Cent Os x64" and "I can not connect to it on either machines" are you having difficulty with? – ODelibalta Jul 04 '12 at 16:07
  • 1
    What happens when you try `install.packages('RMySQL',type='source')`? – nograpes Jul 04 '12 at 16:10
  • 2
    You have not described the versions of these packages nor your OS and you have not offered the error message you got during compilation. (Nor did you say _how_ you attempted installation on Windows7 and whether you had installed Rtools, which led me to believe you tried it from the GUI.) – IRTFM Jul 04 '12 at 16:11
  • My Os "I have R installed on two machines running Windows 7 x64 and Cent Os x64." My package I am trying to install "The R book I have suggests installing RMySQL" The error massage "it spits out the same error on both machines. package 'RMySQL' is not available (for R version 2.15.0)" These are all from my first question post. Please read carefully before comment and please stay on topic Thanks – ODelibalta Jul 04 '12 at 16:27
  • @nograpes I did what you suggested. Thanks. It spit out bunch of stuff. I can copy it here if you wish. At the end it says "installation of package 'RMySQL' had non-zero exit status" so I am looking into that now. Thank you ! – ODelibalta Jul 04 '12 at 16:33
  • 1
    Yes, please edit your question and add the exact error message. Also, did you check out this instruction page (http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL)? I think that will help you. – nograpes Jul 04 '12 at 16:37
  • @nograpes That worked for my linux box. Thank you ! – ODelibalta Jul 04 '12 at 16:41
  • @nograpes I found this and gonna try it. [link](http://stackoverflow.com/questions/4785933/adding-rmysql-package-to-r-fails) – ODelibalta Jul 04 '12 at 16:43
  • The instructions at http://cran.r-project.org/web/packages/RMySQL/INSTALL are fairly explicit that you need to install the package using the Windows command line, not the R terminal. Have you tried that? – Andrie Jul 04 '12 at 16:56
  • Can you also post the results of `Sys.getenv('MYSQL_HOME')` and `readRegistry("SOFTWARE\\MySQL AB", hive="HLM", maxdepth=2) ` – nograpes Jul 04 '12 at 16:59
  • @Andrie Several Windows users have reported success with installing from R. I think that reference in the documentation was saying "Don't type R CMD INSTALL into your R console", not that you can't install from the R console. – nograpes Jul 04 '12 at 17:00
  • @Andrie I've tried it in cmd, R console, R studio and not a chance. I have not tried the steps I mentioned above yet but I ran the cmd again now that you mentioned it to get the output. It has been edited in to my first question post. I appreciate the help. – ODelibalta Jul 04 '12 at 17:09
  • @nograpes getenv returns an empty result which is weird because I did set it in cmd `set MYSQL_HOME=C:\\Program Files\\MySQL\\MySQL Server 5.5.` readRegistry puts out this. `MySQL Connector/ODBC 5.1 MySQL Connector/ODBC 5.1 $Version [1] "5.1.11"` – ODelibalta Jul 04 '12 at 17:18
  • I have found that RStudio doesn't read any updated Windows configuration settings. Are you trying this in RStudio or RTerm/RGui? – Andrie Jul 04 '12 at 17:21
  • I ran getenv and regRegistry in R Console. I've set MYSQL_HOME and R CMD INSTALL RMySQL_0.9-3.tar.gz in windows command prompt. – ODelibalta Jul 04 '12 at 17:24

1 Answers1

0

I moved this to an answer instead of just a big list of comments. I'll edit the post as it goes along.

It is critical that you get your MYSQL_HOME path correct. First, you should note that it is incorrect to double backslash in cmd. For example, your set statement at the prompt should have been:

set MYSQL_HOME=C:\Program Files\MySQL\MySQL Server 5.5

You should also note that this only sets the variable temporarily, and only within the command prompt. So, if you don't start R from that same command prompt, MYSQL_HOME will not be set correctly.

To permanently set your MYSQL_HOME variable, go through your System Properties -> Advanced -> Environment Variables, and create a new System variable called MYSQL_HOME and set the path correctly. Again, no double backslashes.

Restart R or you will not see any changes in the environment variables.

nograpes
  • 18,623
  • 1
  • 44
  • 67
  • Done. Same result. I mean it now returns the location for that variable but still cant install the package. Its weird that the installation source information uses double slashes thats why I did mine like that. – ODelibalta Jul 04 '12 at 18:15
  • Actually, when R escapes the \'s, but Windows doesn't, so it does make sense. – nograpes Jul 04 '12 at 21:38
  • I must agree that this question is totally a duplicate of that other question. Have you made sure that your `PATH` is the same, and have you copied all the files into the relevant directories? – nograpes Jul 04 '12 at 21:41