Wednesday, February 8, 2012

RMySQL - How to connect R with MySQL in Windows

Following the instructions of http://stackoverflow.com/questions/4785933/adding-rmysql-package-to-r-fails

Important note 1: The installation works when using MySQL for 32bit computers and R for 32bit computers. I have tried to install it to the 64bit version of R but I did not succeed.
  • Install RTools
  • Install MySQL or header and library files of mysql
  • Create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add two lines like CYGWIN=nodosfilewarning
    MYSQL_HOME=C:/ARCHIV~1/MYSQL/MYSQLS~1.5
  • Copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.
  • Copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory.
  • Run install.packages('RMySQL',type='source') and wait while compilation will end.
Important note 2: My computer contains Spanish language Windows, and I had several problems with the accent in the folder named "Configuración local", where the downloaded packages are stored and compiled.
I solved the problem in the following way. I changed the environment variable TMP to another local folder without containing any accent.
After the installation I rolled back the change in the environment variable.

No comments:

Post a Comment