2011
11.08

While installing RMySQL on OS X and Linux is really simple this is not the case for Windows. After trying several how to’s RMySQL still wasn’t working. Then I started experimenting my self… With success!

This is what I did:

  • Install R 2.14
  • Install R tools (2.14) (with modifying path option)
  • Install MySQL (5.5.17) (with modifying path option)
  • Create the file Renviron.site in the folder C:\Program Files\R\R-2.14.0\etc and add:

    MYSQL_HOME=C:/Program Files/MySQL/MySQL Server 5.5
    
  • Copy libmysql.lib and libmysql.dll from

    C:\Program Files\MySQL\MySQL Server 5.5\lib to
    C:\Program Files\MySQL\MySQL Server 5.5\lib\opt (must be created)

  • Copy libmysql.dll from
    C:\Program Files\MySQL\MySQL Server 5.5\lib to
    C:\Program Files\R\R-2.14.0\bin\i386
  • Open R and install RMYSQL

    install.packages('RMySQL', type = 'source');
    

If everything went well you’ll now be able to load the RMySQL package by invoking:

library(RMySQL);

in R.

Resources:

9 comments so far

Add Your Comment
  1. karishma

    Hi ..I did everything you said , but it still gives me following error while trying to install RMySQL :

    ERROR: configuration failed for package ‘RMySQL’
    * removing ‘C:/Program Files/R/R-2.15.0/library/RMySQL’.

    Also For your information i am using XAMPP for installing mysql

  2. bart

    Did you really test it? I have the same problem as Karishma

  3. tersmitten

    Yes, but I didn’t use a XAMP installation. I installed MySQL from MySQL’s website.

  4. siva

    I am getting following error, Please help me out

    Warning: unable to access index for repository http://cran.revolutionanalytics.com/src/contrib
    Warning: unable to access index for repository http://www.stats.ox.ac.uk/pub/RWin/src/contrib
    Warning message:
    In getDependencies(pkgs, dependencies, available, lib) :
    package ‘RMySQL’ is not available (for R version 2.14.2)

  5. tersmitten

    That’s because you have to build RMySQL yourself. There’s no package for Windows.

  6. Srinivas

    Thanks a lot. Was really helpful 🙂

  7. Sine

    Thanks – it looks usefull. Any ideas on what to do if the mySQL-connection is a database server not installed locally? I would think it could be something like:
    MYSQL_HOME= serwername, but then all this moving libs around is not really possible?

  8. Tao

    ERROR: configuration failed for package ‘RMySQL’
    * removing ‘F:/R/R-2.15.2/library/RMySQL’

    I using XAMPP to install the mysql 5.5.25a . it’s not working for the steps.
    I guess these steps just adjust the version 5.5.17 of mysql.