rrmysql

installing RMySQL package on Mac Catallina


I tried to install RMySQL package in my Rstudio, and when I tried it, it gave me following error

> install.packages("RMySQL")
Installing package into ‘/Users/haeseongmoon/Library/R/3.6/library’
(as ‘lib’ is unspecified)
Warning in install.packages :
  unable to access index for repository https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6:
  cannot open URL 'https://cran.rstudio.com/bin/macosx/el-capitan/contrib/3.6/PACKAGES'
Package which is only available in source form, and may need compilation of
  C/C++/Fortran: ‘RMySQL’
Do you want to attempt to install these from sources? (Yes/no/cancel) Yes
installing the source package ‘RMySQL’

trying URL 'https://cran.rstudio.com/src/contrib/RMySQL_0.10.20.tar.gz'
Content type 'application/x-gzip' length 52900 bytes (51 KB)
==================================================
downloaded 51 KB

* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
** using staged installation
Using PKG_CFLAGS=
Using PKG_LIBS=-lmysqlclient
-----------------------------[ ANTICONF ]-----------------------------
Configure could not find suitable mysql/mariadb client library. Try installing:
 * deb: libmariadbclient-dev | libmariadb-client-lgpl-dev (Debian, Ubuntu)
 * rpm: mariadb-connector-c-devel | mariadb-devel | mysql-devel (Fedora, CentOS, RHEL)
 * csw: mysql56_dev (Solaris)
 * brew: mariadb-connector-c (OSX)
If you already have a mysql client library installed, verify that either
mariadb_config or mysql_config is on your PATH. If these are unavailable
you can also set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------[ ERROR MESSAGE ]----------------------------
<stdin>:1:10: fatal error: 'mysql.h' file not found
#include <mysql.h>
         ^~~~~~~~~
1 error generated.
-----------------------------------------------------------------------
ERROR: configuration failed for package ‘RMySQL’
* removing ‘/Users/haeseongmoon/Library/R/3.6/library/RMySQL’
Warning in install.packages :
  installation of package ‘RMySQL’ had non-zero exit status

The downloaded source packages are in
    ‘/private/var/folders/c6/qgbzrx0s4zq7gdbhzz43gqhw0000gn/T/RtmpOozjqL/downloaded_packages’

I tried various solutionns that I found while I was doing googling, but it didn't workout. How can I install RMySQL?


Solution

  • Thankfully, the error tells you exactly what to do.

    Configure could not find suitable mysql/mariadb client library. Try installing:
     * deb: libmariadbclient-dev | libmariadb-client-lgpl-dev (Debian, Ubuntu)
     * rpm: mariadb-connector-c-devel | mariadb-devel | mysql-devel (Fedora, CentOS, RHEL)
     * csw: mysql56_dev (Solaris)
     * brew: mariadb-connector-c (OSX)
    

    You need to use homebrew to install mariadb-connector-c.

    brew install mariadb-connector-c
    

    If you don't have homebrew yet, check out this page.