Skip to main content

Installing RMySQL on OS X "Yosemite"

Here are the instructions to install RMySQL on OS X "Yosemite":

  1. Download and install the MySQL community server for OS X. You will need a free Oracle account to complete the download. At the time of this blog post, I installed mysql-5.6.22-osx10.9-x86_64 via the DMG archive. By default MySQL will be installed in /usr/local/mysql-5.6.22-osx10.8-x86_64 (if you use a different version, look for an equivalently named directory under /usr/local).
  2. Download sources for the RMySQL package from CRAN. At the time of this blog post, I downloaded RMySQL_0.9-3.tar.gz.
  3. Open a Terminal window and run:
    export DYLD_LIBRARY_PATH=/usr/local/mysql-5.6.22-osx10.8-x86_64/lib:$DYLD_LIBRARY_PATH
    You may want to consider adding this line to .bashrc as well.
  4. In the same terminal window compile and install RMySQL using this command (in a single line):
    R CMD INSTALL --configure-args="--with-mysql-dir=/usr/local/mysql-5.6.22-osx10.8-x86_64 --with-mysql-inc=/usr/local/mysql-5.6.22-osx10.8-x86_64/include --with-mysql-lib=/usr/local/mysql-5.6.22-osx10.8-x86_64/lib" RMySQL_0.9-3.tar.gz
    If you installed a different version of MySQL or downloaded a different version of RMySQL, fix the command to reflect the correct directory names.
That should be it. RMySQL will build and, if everything went well, finish up with these messages:
** testing if installed package can be loaded
* DONE (RMySQL)
From the terminal window launch R as usual.

If you are using RStudio, and simply launch it from Spotlight or your Applications folder, and try to use RMySQL, you may see this error:
> library(RMySQL)
Loading required package: DBI
Error : .onLoad failed in loadNamespace() for 'RMySQL', details:
  call: dyn.load(file, DLLpath = DLLpath, ...)
  error: unable to load shared object '/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RMySQL/libs/RMySQL.so':
  dlopen(/Library/Frameworks/R.framework/Versions/3.1/Resources/library/RMySQL/libs/RMySQL.so, 6): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Library/Frameworks/R.framework/Versions/3.1/Resources/library/RMySQL/libs/RMySQL.so
  Reason: image not found
Error: package or namespace load failed for ‘RMySQL’
This is because the DYLD_LIBRARY_PATH environment variable is only set in Terminal windows. You have two options to use RStudio:

  1. Open a Terminal window and run
    export DYLD_LIBRARY_PATH=/usr/local/mysql-5.6.22-osx10.8-x86_64/lib:$DYLD_LIBRARY_PATH
    /Applications/RStudio.app/Contents/MacOS/RStudio &
  2. As root, add the "export ..." line to /etc/launchd.conf and restart your computer. This should make the DYLD_LIBRARY_PATH setting global and allow you to launch RStudio from Spotlight or your Applications folder.

Comments

Popular posts from this blog

FCC Aproves Sirius-XM Merger

This has been a long time coming but finally the FCC has finally approved the merger of Sirius Satellite Radio with XM Satellite Radio . The combined entity is pretty much a monopoly in the satellite radio space but they are still competing with terrestrial radio. Either way, their stocks, NASDAQ:SIRI and NASDAQ:XMSR should get a good boost on Monday. Yahoo! Finance Quote for SIRI Quote for XMSR

Lead Tide SIM Reader

I recently came across a cheap little device for reading SIM cards . It was available from Meritline for less than USD 5 with free shipping. Curious to see what it was like, I ordered one. The device came in a small package along with a mini CD containing drivers. The packaging advertised the device as the LEAD TIDE Sim reader . Like most things these days, it's made in China. The device has a USB 1.1 interface. There was no product code or number anywhere on the packaging. Installing the drivers for the device turned out to be harder than I expected. The mini CD's autorun installed some stuff but Microsoft Windows XP couldn't install any suitable driver for the device. The mini-CD had several top level directories with what appeared to be product codes but I couldn't match any to the device itself since it had no product code. Google searches revealed that I wasn't alone in my endeavors to get the device working . Further digging revealed pointers to some thir

Getting Mailvelope on Chrome to use GnuPG on macOS

Mailvelope is a browser add-on that helps use GPG encryption and signing on webmail systems like Gmail. Here are the steps on macOS (tested with "Big Sur") to get Mailvelope to use the GnuPG backend. Install gpgme via Homebrew: brew install gpgme This will install gpgme-json in /usr/local/bin by default.  Create a file called gpgmejson.json in  "~/Library/Application Support/Google/Chrome/NativeMessagingHosts" with the following contents: {     "name": "gpgmejson",     "description": "Integration with GnuPG",     "path": "/usr/local/bin/gpgme-json",     "type": "stdio",     "allowed_origins": [         "chrome-extension://kajibbejlbohfaggdiogboambcijhkke/"     ] } Now in Mailvelope > Options > General , GnuPG will show up as the encryption backend.