Skip to content

Instantly share code, notes, and snippets.

@labeneator
Created October 4, 2013 21:49
Show Gist options
  • Save labeneator/6833376 to your computer and use it in GitHub Desktop.
Save labeneator/6833376 to your computer and use it in GitHub Desktop.
RMySQL OSX recipe
# Find your R home
$ echo "R.home()" | Rscript /dev/stdin
Loading required package: stats
Loading required package: methods
[1] "/usr/local/Cellar/r/3.0.1/R.framework/Resources"
# Make sure that you have the MySQL home var in your Renviron
$ fgrep MYSQL_HOME /usr/local/Cellar/r/3.0.1/R.framework/Resources/etc/Renviron
MYSQL_HOME="/usr/local/mysql-5.6.12-osx10.7-x86_64/"
#### This step trips up everyone ####
# Make sure that the libmysqlclient dynamic lib is in your R lib path by
# 1. Get the dll path
$ echo "Sys.getenv('DYLD_FALLBACK_LIBRARY_PATH')" | Rscript /dev/stdin
Loading required package: stats
Loading required package: methods
[1] "/usr/local/Cellar/r/3.0.1/R.framework/Resources/lib"
# 2. Symlink your libmysqlclient
$ ln -s /usr/local/mysql-5.6.12-osx10.7-x86_64/lib/libmysqlclient.18.dylib /usr/local/Cellar/r/3.0.1/R.framework/Resources/lib
# 3. Install the package
$ export PKG_LIBS="-L/usr/local/mysql-5.6.12-osx10.7-x86_64/lib/ -lmysqlclient"
$ export PKG_CPPFLAGS="-I/usr/local/mysql-5.6.12-osx10.7-x86_64/include/"
$ R CMD INSTALL RMySQL.tar.gz
...
...
** installing vignettes
** testing if installed package can be loaded
* DONE (RMySQL)
@naresh-sundarrajan
Copy link

Works Perfect~! Had to tweak few paths for non-homebrew R installations. Thanks a lot! :)

@labeneator
Copy link
Author

:)

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