adding RMySQL package to R fails (on Windows)?

Solution 1:

The basic process is described here, but there are several hints, So I will describe the whole solution (please change the R version and paths if needed):

  1. Install latest RTools from here
  2. install MySQL or header and library files of mysql
  3. create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files)
  4. copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.
  5. copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory.
  6. run install.packages('RMySQL',type='source') and wait while compilation will end.

This worked for me on Windows 7 64 bit, so there should be no problems with 32 bit versions

Initialy posted here (similar question).

Solution 2:

First I would try following the directions on this page: http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL

Then, ensure that you actually have a MySQL client on your computer, not just the server itself. I've had a problem myself where I had to use an older binary for the client, but you can download these from mysql website.

Solution 3:

I created a binary which might work for people:

http://kenahoo.blogspot.com/2011/09/rmysql-binary-for-windows-7.html

I basically followed all these directions, including the ones at the Vanderbilt page, but for one reason or another it doesn't always seem to work. Anyway, hope this might be helpful for people who have the same versions of stuff I used.

Solution 4:

I was having this same problem on Windows 7 with R 2.12.1 x64 and resolved it by:

  1. Changing the R directory in my PATH variable to C:\Program Files\R\R-2.12.1\bin\x64 (rather than just ...\R-2.12.1\bin).
  2. Copying ...\MySQL Server 5.5\lib\libmysql.dll to ...\MySQL Server 5.5\bin\.
  3. Running R CMD INSTALL RMySQL_0.7-5.tar.gz in cmd.exe (install.packages('RMySQL',type='source') in R still would not work).

Solution 5:

I came across this step-by-step guide to install RMySQL under Windows7 64bit.

http://www.ahschulz.de/2013/07/23/installing-rmysql-under-windows/

The software I used are:

  1. Windows 8 OS
  2. R3.0.2 - 64bit
  3. Rtools 3.1
  4. MySQL Server Community Edition 5.6 - 64bit

Following the above guide (with screenshots provided), my installation and loading of the RMySQL package works.

Many thanks to Arne Hendrik Schulz!