RMySQL is the database interface and MySQL driver for R. If you don’t already have MySQL libraries and try to install it, you could get an error like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
> install.packages("RMySQL") 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 ‘/home/patlaf/R/x86_64-pc-linux-gnu-library/3.0/RMySQL’ Warning in install.packages : installation of package ‘RMySQL’ had non-zero exit status The downloaded source packages are in ‘/tmp/RtmpZQyvFJ/downloaded_packages’ |
This is because the installation don’t find the required MySQL C API libraries. You can manually download them and specify the path as arguments, but a much simpler way is to use apt-get:
1 |
sudo apt-get install libmysqlclient-dev |
Then, in your R environment you can reinstall the package!