Skip to content

Instantly share code, notes, and snippets.

@cheyuriy
Last active August 29, 2015 14:03
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save cheyuriy/6f78d83570f6d737c176 to your computer and use it in GitHub Desktop.
Save cheyuriy/6f78d83570f6d737c176 to your computer and use it in GitHub Desktop.
Installing RMySQL on Windows 7 x64 (or similar)

Installing RMySQL on Windows 7 x64 (or similar)

###Step 1. Install RTools. Head to official CRAN page http://cran.r-project.org/ and install the latest available RTools for your R version. Install both x86 and x64 versions to save your nerves.

###Step 2. Installing MySQL connectors Install MySQL C Connectors from official MySQL resource: http://dev.mysql.com/downloads/connector/c/ .

Make sure, that you're installing correct version which corresponds to your platform (x64).

Also check, that you've included installation of all components of C Connector in installation wizard (maybe exluding Documentation).

###Step 3. Create Renviron.site configuration file Head to your R installation, find directory etc and create file Renviron.site.

Add one line:

MYSQL_HOME=C:/MySQL/ConnectorC

(specify your own installation path from step 2, note that there are no ending backslash)

Save it. ####Step 3b (optional). Add MySQL location in registry Open your regedit (click Win+R, type "regedit" and click Enter).

Create node HKEY_LOCAL_MACHINE\SOFTWARE\MySQL AB.

Then create just one key in this node: string parameter Location with value from your $MYSQL_HOME variable.

###Step 4. Move MySQL dll to bin folder Open your MySQL C Connector installation directory (which placed in $MYSQL_HOME variable before) and copy libmysql.dll from /lib directory to /bin directory.

###Step 5. Run your RStudio and install package. Now you can simply install RMySQL package from sources using command:

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

Check that everything is OK with command:

library(RMySQL)

###Step 6. Enjoy!

@DaveW001
Copy link

Thanks for the tutorial. Very helpful.

I had to take one additional step, although it may have been the result of something I did incorrectly.

  • Copy "C:\Program Files\MySQL\MySQL Connector C 6.1.5\lib\libmysql.dll" to C:\Program Files\MySQL\MySQL Connector C 6.1.5\bin\libmysql.dll

@calchad
Copy link

calchad commented Aug 11, 2014

Thank you very much for the memo - you have laid it out well.

@jamespaultg
Copy link

Thanks a lot. This is helpful

@benja-ct
Copy link

Thank you so much!!! your 2 hours saved me tens of mine!!!

@heying1010
Copy link

Thank you so much. I suffered this for a few days

@roofTiles
Copy link

how do you create the renviron.site file?

@cheyuriy
Copy link
Author

just create. with touch command, text editor or any other way

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment