Friday, 3 January 2014

Installation of RMySQL Package into R3.0.2 - Windows 7

I think this is definitely worth posting on my blog because I have almost spent half day to figure out the installation of RMySQL package in R Console.

This package helps us to connect to the schema/database from R and then use the tables or create data frames with the connected table and then perform the further analysis. This will definitely help to save lot of time in terms of first exporting the data from sql to .csv and then importing to R from .csv for data analysis, modelling, etc

Here is the step by step procedure to install the package
1.       Firstly, a normal install.packages(libname) will not work in case of RMySQL. It has to be installed and compiled with the source
2.       It is required to first download and install Rtools exe depending upon the R Console Version. Here is the link to choose from - http://cran.r-project.org/bin/windows/Rtools/
3.       It is indeed required and mandatory to check box the system path in the process of installation
a.       Firstly, user will see this window prompt



b.      Ensure to check 2 boxes after clicking the next


c.       Click next and complete the installation

4.       Create an Environment Variable in the local system.
a.       Go to Control Panel àUser Account à Change my Environment variables
b.      Click on New
c.       Give the Variable name as MYSQL_HOME
d.      Give the Variable path as C:/Program Files/MySQL/MySQL Server 5.6(**Slash, this is not back slash as in case of path copy)
e.      It should look something like the below one

5.       Locate "libmysql.dll" file from the mysql program instance. Generally, this will be available in the bin folder of the Mysql instance in the program files
6.       Copy that ".dll" file and paste it in the R Environment into the bin folder. Generally, the path would be something like Program Files à R à R-3.02 à bin à x64/x32 à Copy that Mysql dll file into the path
7.       Restart the R-Console
8.       Run the Install Packages command by typing the following and selecting the respective CRAN

9.       Installation should work and you can connect to the database and access the tables

10.   Reference Manual is available in the package help

2 comments: