Question

The system info relevant to my problem:

AWS RDS DB Instance
Instance Class - db.m1.small
Engine - MySQL 5.6.13

AWS EC2 Linux AMI
https://aws.amazon.com/amazon-linux-ami/2014.03-release-notes/

R version 3.0.2
i686-redhat-linux-gnu (32-bit)

Linux MySQL packages installed:
mysql.noarch            5.5-1.6.amzn1        @amzn-main   
mysql-server.noarch     5.5-1.6.amzn1        @amzn-main   
mysql55.i686            5.5.37-1.46.amzn1    @amzn-updates
mysql55-common.i686     5.5.37-1.46.amzn1    @amzn-updates
mysql55-libs.i686       5.5.37-1.46.amzn1    @amzn-updates
mysql55-server.i686     5.5.37-1.46.amzn1    @amzn-updates

I have R installed on the aforementioned AWS Linux AMI. I'm trying to pull data from my RDS instance running MySQL into R data frames.

As it stands currently, I have installed the DBI package into R, but installing RMySQL is failing with the following error:

$> R CMD INSTALL RMySQL_0.9-3.tar.gz
* installing to library ‘/usr/lib/R/library’
* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables... 
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ANSI C... none needed
checking how to run the C preprocessor... gcc -E
checking for compress in -lz... yes
checking for getopt_long in -lc... yes
checking for mysql_init in -lmysqlclient... no
checking for egrep... grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking mysql.h usability... no
checking mysql.h presence... no
checking for mysql.h... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking for mysql_init in -lmysqlclient... no
checking /usr/local/include/mysql/mysql.h usability... no
checking /usr/local/include/mysql/mysql.h presence... no
checking for /usr/local/include/mysql/mysql.h... no
checking /usr/include/mysql/mysql.h usability... no
checking /usr/include/mysql/mysql.h presence... no
checking for /usr/include/mysql/mysql.h... no
checking /usr/local/mysql/include/mysql/mysql.h usability... no
checking /usr/local/mysql/include/mysql/mysql.h presence... no
checking for /usr/local/mysql/include/mysql/mysql.h... no
checking /opt/include/mysql/mysql.h usability... no
checking /opt/include/mysql/mysql.h presence... no
checking for /opt/include/mysql/mysql.h... no
checking /include/mysql/mysql.h usability... no
checking /include/mysql/mysql.h presence... no
checking for /include/mysql/mysql.h... no

Configuration error:
  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.

INSTRUCTIONS:

1. Define and export the 2 shell variables PKG_CPPFLAGS and
   PKG_LIBS to include the directory for header files (*.h)
   and libraries, for example (using Bourne shell syntax):

      export PKG_CPPFLAGS="-I<MySQL-include-dir>"
      export PKG_LIBS="-L<MySQL-lib-dir> -lmysqlclient"

   Re-run the R INSTALL command:

      R CMD INSTALL RMySQL_<version>.tar.gz

2. Alternatively, you may pass the configure arguments
      --with-mysql-dir=<base-dir> (distribution directory)
   or
      --with-mysql-inc=<base-inc> (where MySQL header files reside)
      --with-mysql-lib=<base-lib> (where MySQL libraries reside)
   in the call to R INSTALL --configure-args='...' 

   R CMD INSTALL --configure-args='--with-mysql-dir=DIR' RMySQL_<version>.tar.gz

ERROR: configuration failed for package ‘RMySQL’
* removing ‘/usr/lib/R/library/RMySQL’

It's clear that I need to direct the installation to where MySQL is installed, but I don't know where to start to locate the proper directory. I did the following to try to look around:

$> find / -name mysql
/usr/share/mysql
/usr/lib/perl5/vendor_perl/auto/DBD/mysql
/usr/lib/perl5/vendor_perl/DBD/mysql
/usr/lib/mysql
/usr/bin/mysql
/var/lib/mysql
/var/lib/mysql/mysql

So there's a lot of different MySQL directories on my AWS Linux instance. Which one do I use in the installation path? Should I do trial and error?

My other question is (assuming I install RMySQL properly), does the MySQL server have to be running on the same physical (virtual?) machine where R is also installed in order for RMySQL to work?

Other research has shown that a SSH tunnel has to be created for the RMySQL connection to the MySQL database to work. Is this true? If I'm not mistaken, AWS RDS doesn't allow for SSH tunneling.

Any other suggestions?

Was it helpful?

Solution

You missed the most important line in the configure output:

checking for mysql.h... no

You have the run-time package(s) for MySQL installed. You now need the development packages.

Under Debian/Ubuntu we impose these Build-Depends (and I just edited away the minimal version requirements):

Build-Depends: debhelper, cdbs, r-base-dev, libmysqlclient-dev, r-cran-dbi

The first two are Debian-packaging internal, the third is R, the fourth is MySQL and you need to map that to whatever RH/FC call it and the last one is DBI for R.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top