1. Download MySQL from dev.mysql.com. Make sure to get the 64-bit version.
2. Uncompress mysql-xxx.tar.gz somewhere which we’ll now refer to as MYSQL_HOME. It should contain directories such as bin, lib, and include.
3. Download R from CRAN.
4. Download RMySQL package source from CRAN. We’ll refer to the path of that RMySQL_xxx.tar.gz as RMYSQL_PATH.
5. Before installing RMySQL, we need to place libmysqlclient.18.dylib in a place where RMySQL can find it. sudo ln -s MYSQL_HOME/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib.
6. In terminal, use the following command to install RMySQL. R CMD INSTALL –configure-args=’–with-mysql-dir=MYSQL_HOME –with-mysql-inc=MYSQL_HOME/include –with-mysql-lib=MYSQL_HOME/lib’ RMYSQL_PATH. This is documented as one of the options in the installation guide.
7. library(RMySQL) should know work in the R interactive shell.
These steps will get you over these ugly errors:
** testing if installed package can be loaded
Error : .onLoad failed in loadNamespace() for ‘RMySQL’, details:
call: dyn.load(file, DLLpath = DLLpath, …)
error: unable to load shared object ‘/usr/local/Cellar/r/2.15.2/R.framework/Versions/2.15/Resources/library/RMySQL/libs/RMySQL.so’:
dlopen(/usr/local/Cellar/r/2.15.2/R.framework/Versions/2.15/Resources/library/RMySQL/libs/RMySQL.so, 6): Library not loaded: libmysqlclient.18.dylib
Referenced from: /usr/local/Cellar/r/2.15.2/R.framework/Versions/2.15/Resources/library/RMySQL/libs/RMySQL.so
Reason: image not found
Error: loading failed
ERROR: loading failed
— and —
could not find the MySQL installation include and/or library
directories. Manually specify the location of the MySQL
libraries and the header files and re-run R CMD INSTALL.