Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using MySQL in R for Windows

Tags:

mysql

windows

r

How to use MySQL in R (statistic language) for Windows (7)?

There is no problems then using linux:

install.packages('RMySQL')
library(RMySQL)
...

But I found no such package for Windows on CRAN. There is only note about this fact. I found package for version 2.10, but it is not usable in 2.12.1.

Also tried

install.packages("RMySQL", type="source")

but got an error :

* installing *source* package 'RMySQL' ... 
ERROR: configuration failed for package 'RMySQL'
* removing 'C:/.../R/win-library/2.12/RMySQL'

Is there any way to connect to MySQL database from R in windows?

like image 989
Yuriy Petrovskiy Avatar asked Mar 07 '11 17:03

Yuriy Petrovskiy


People also ask

Can you use MySQL with R?

R can connect to all these relational databases to fetch records from them. The RMySQL packages, helps make a connection between the R environment and the MySQL server. After the connection is made, the data set can be manipulated and analyzed using various functions.

Why would you want to use MySQL with R?

Clearly, using MySQL with R will not only prevent unnecessary data clogging the memory but also saves time since the chunkWise approach cuts the writing time down significantly.


1 Answers

Found solution with help of ran2, who gave me link to common question. 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.

Thanks to all who tried to answer.

like image 73
Yuriy Petrovskiy Avatar answered Oct 11 '22 20:10

Yuriy Petrovskiy