Centos 在安装 RMySQL 中遇到了许多问题,现在一一记下来,希望下次不要为了同样的问题烦恼
注意:ubuntu 安装非常方便只需安装如下工具,然后正常安装即可:
clebeg@clebeg:~$ sudo apt-get install libdbd-mysql libmysqlclient-dev
环境介绍:
[root@localhost download]# uname -a
Linux localhost.localdomain 2.6.32-358.el6.i686 #1 SMP Thu Feb 21 21:50:49 UTC 2013 i686 i686 i386 GNU/Linux
[root@localhost download]# R --version
R version 3.0.3 (2014-03-06) -- "Warm Puppy"
Copyright (C) 2014 The R Foundation for Statistical Computing
Platform: i686-pc-linux-gnu (32-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under the terms of the
GNU General Public License versions 2 or 3.
For more information about these matters see
http://www.gnu.org/licenses/.
[root@localhost download]# mysql --version
mysql Ver 14.14 Distrib 5.6.16, for Linux (i686) using EditLine wrapper
[root@localhost download]# cat /etc/issue
CentOS release 6.4 (Final)
Kernel \r on an \m
1、首先尝试直接安装:
> install.packages("RMySQL")
试开URL’http://cran.rstudio.com/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb)
打开了URL
==================================================
downloaded 161 Kb
* installing *source* package ‘RMySQL’ ...
** 成功将‘RMySQL’程序包解包并MD5和检查
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... yes
checking /usr/include/mysql/mysql.h presence... yes
checking for /usr/include/mysql/mysql.h... yes
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/local/lib/R/library/RMySQL’
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘/tmp/Rtmpt7qePJ/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
2、很不幸运,报了错误,分析原因
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.
分析上面的日子:发现 R 无法找到 MySQL 安装的 include 和 lib 头文件,提示要自己取下载,然后手动安装,用下面的命令:
R CMD INSTALL --configure-args='--with-mysql-dir=DIR' RMySQL_<version>.tar.gz
3、安装链接MySQL 的编译头文件
幸亏懂一点点编译原理,下载下面的连接C
[root@localhost download]# ls
mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit
mysql-connector-c-6.0.2-linux-glibc2.3-x86-32bit.tar.gz
mysql-connector-c-6.1.3-linux-glibc2.5-i686
mysql-connector-c-6.1.3-linux-glibc2.5-i686.tar.gz
//特别注意,我的MySQL是最新的,但是不能用最新的connector去编译RMySQL,我第一用最新的报错报的惨惨
//然后拷贝文件到相关目<pre code_snippet_id="231364" snippet_file_name="blog_20140312_5_4505622" name="code" class="html">[root@localhost download]#cp -R /home/clebeg/download/mysql-connector-c-6.0.2-linux-glibc2.5-i686/include/. /usr/local/lib/R/include/.
<pre code_snippet_id="231364" snippet_file_name="blog_20140312_5_4505622" name="code" class="html"><pre code_snippet_id="231364" snippet_file_name="blog_20140312_5_4505622" name="code" class="html">[root@localhost download]#cp -R /home/clebeg/download/mysql-connector-c-6.0.2-linux-glibc2.5-i686/lib/. /usr/local/lib/R/lib/.
//最后手动安装DBI,和RMySQL
<pre code_snippet_id="231364" snippet_file_name="blog_20140312_5_4505622" name="code" class="html"><pre code_snippet_id="231364" snippet_file_name="blog_20140312_5_4505622" name="code" class="html"><pre code_snippet_id="231364" snippet_file_name="blog_20140312_5_4505622" name="code" class="html"><pre code_snippet_id="231364" snippet_file_name="blog_20140312_5_4505622" name="code" class="html">[root@localhost ~]# R CMD INSTALL (DBI-0.2-7)
[root@localhost ~]# R CMD INSTALL --configure-args='--with-mysql-inc=/usr/local/lib/R/include/'
R语言连接MySQL windows
http://bbs.pinggu.org/thread-2132410-1-1.html