我无法在 EC2 实例中的 ubuntu 16.04 中的 R 中安装“RMySQL”包

我无法在 EC2 实例中的 ubuntu 16.04 中的 R 中安装“RMySQL”包
> install.packages("RMySQL")
Installing package into ‘/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
Secure CRAN mirrors
 1: 0-Cloud [https]                 2: Algeria [https]
 3: Australia (Canberra) [https]    4: Australia (Melbourne) [https]
 5: Australia (Perth) [https]       6: Austria [https]
 7: Belgium (Ghent) [https]         8: Brazil (RJ) [https]
 9: Brazil (SP 1) [https]          10: Bulgaria [https]
11: Chile 1 [https]                12: China (Lanzhou) [https]
13: Colombia (Cali) [https]        14: Czech Republic [https]
15: Denmark [https]                16: Estonia [https]
17: France (Lyon 1) [https]        18: France (Lyon 2) [https]
19: France (Marseille) [https]     20: France (Montpellier) [https]
21: France (Paris 2) [https]       22: Germany (Göttingen) [https]
23: Germany (Münster) [https]      24: Greece [https]
25: Iceland [https]                26: Indonesia (Jakarta) [https]
27: Ireland [https]                28: Italy (Padua) [https]
29: Japan (Tokyo) [https]          30: Malaysia [https]
31: Mexico (Mexico City) [https]   32: Norway [https]
33: Philippines [https]            34: Russia (Moscow) [https]
35: Serbia [https]                 36: Spain (A Coruña) [https]
37: Spain (Madrid) [https]         38: Sweden [https]
39: Switzerland [https]            40: Turkey (Denizli) [https]
41: Turkey (Mersin) [https]        42: UK (Bristol) [https]
43: UK (Cambridge) [https]         44: UK (London 1) [https]
45: USA (CA 1) [https]             46: USA (IA) [https]
47: USA (KS) [https]               48: USA (MI 1) [https]
49: USA (OR) [https]               50: USA (TN) [https]
51: USA (TX 1) [https]             52: Vietnam [https]
53: (other mirrors)
Selection: 44
trying URL 'https://cran.ma.imperial.ac.uk/src/contrib/RMySQL_0.10.11.tar.gz'
Content type 'application/x-gzip' length 54186 bytes (52 KB)
==================================================
downloaded 52 KB
* installing *source* package ‘RMySQL’ ...
** package ‘RMySQL’ successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=
Using PKG_LIBS=-lmysqlclient
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libmysqlclient was not found. Try installing:
 * deb: libmariadb-client-lgpl-dev (Debian, Ubuntu 16.04)
        libmariadbclient-dev (Ubuntu 14.04)
 * rpm: mariadb-devel | mysql-devel (Fedora, CentOS, RHEL)
 * csw: mysql56_dev (Solaris)
 * brew: mariadb-connector-c (OSX)
If libmysqlclient is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libmysqlclient.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘RMySQL’
* removing ‘/home/ubuntu/R/x86_64-pc-linux-gnu-library/3.4/RMySQL’
The downloaded source packages are in
        ‘/tmp/RtmpmnTu3i/downloaded_packages’
Warning message:
In install.packages("RMySQL") :
  installation of package ‘RMySQL’ had non-zero exit status

答案1

安装以下软件包解决了我的问题:

* deb: libmariadbclient-dev | libmariadb-client-lgpl-dev (Debian, Ubuntu)
* rpm: mariadb-connector-c-devel | mariadb-devel | mysql-devel (Fedora, CentOS, RHEL)
 #yum install mariadb-connector-c-devel mariadb-devel mysql-devel  ----> for RPM based systems 

#apt-get install libmariadbclient-dev libmariadb-client-lgpl-dev   -----> for debian based systems

* deb: unixodbc-dev (Debian, Ubuntu, etc)
* rpm: unixODBC-devel (Fedora, CentOS, RHEL)

#yum install unixODBC-devel   ----> for RPM based systems 
#apt-get install unixodbc-dev -----> for debian based systems

答案2

除了 Santosh 的回答之外,我还必须安装:

sudo apt-get install libmysqlclient-dev
sudo apt-get install zlib1g-dev 

因为我的安装中缺少开发版本,而 RMySQL 需要它们来编译一些 C++ 头文件。

之后,在 Ubuntu 18.04 LTS 中从 RStudio 安装 RMySQL 一切顺利。

我从 2003 年的这个旧回复中得到了灵感在 Debian Linux 上安装 RMySQL 和 MySQL-4.0.12

相关内容