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

Migrating from Palm Calendar to Google Calendar and iPhone

Here are the free steps to migrate from Palm's date book (or Pimlico's DateBk6 ) calendar to Google calendar for full iPhone sync. First, sync Palm with Palm Desktop . Next, open Palm Desktop, select the Calendar view, navigate to File | Export, select Export Type as Date Book Archive, Range as All and provide a file name. This will export the calendar data as Date Book Archive (.dba). There's a paid tool called DBA2CSV that converts .dba files to .csv files. However this can be done for free using Yahoo Calendar. Login into Yahoo Calendar and via Settings/Import, import the .dba file. It helps to have an empty Yahoo Calendar. Via Settings/Export, export the calendar as .csv file. Login to Google Calendar (also works with Google Apps For Your Domain GAFYD Calendar) and import the .csv file into any of the calendars. It is a good idea to create a test calendar and test the import before importing into your real calendar. That way if anything goes wrong, you can delet...

AD-5526 Digital Multimeter

The AD-5526 is an ancient multimeter from A&D but for $10 one can’t complain. Has all the basic features one would expect from a multimeter and at 5.2 cm X 9.5 cm X 2.6 cm, it’s quite compact. Uses a LRV08 12V alkaline battery – not a common battery in the USA.

RTL-SDR, Raspberry Pi and Plane Spotting via ADS-B

Most modern aircraft carry an ADS-B ( Automatic Dependent Surveillance - Broadcast ) transmitter that puts out information about the aircraft's identification, geospatial location, speed, and heading. This information is received by ground stations and air traffic control and used as a replacement for radar-based tracking. ADS-B relies on line-of-sight communication via signals transmitted at 1090 Mhz and has a range of up to 250 nautical miles. Sites such as FlightAware , FlightRadar24 , Plane Finder , RadarBox24 , etc. collect ADS-B information using a vast array of ADS-B receivers, some of which are run by hobbyists, and present this information on maps with near-real-time updates. With the advent of cheap software-defined-radio (SDR) dongles, over the past few years, it has become extremely cheap and easy for amateurs to receive ADS-B signals, upload data to these sites and, in exchange, get access to premium features from these sites. This guide will walk you t...