我正在尝试在Windows 8.1上安装RMySQL。我已经安装了MySQL Server 5.1
和R 3.0.3
。它们都被添加到系统路径中,可以通过在命令提示符下键入mysql -u root -p
或R
从任何地方调用。
我按照此页http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL中的说明安装了Rtools
,然后在我的R安装的Renviron.site
文件夹中创建了一个/etc
文件。在Renviron.site
文件中,我正确设置了MYSQL_HOM
E,如下所示:
MYSQL_HOME="C:\Program Files\MySQL\MySQL Server 5.6"
然后我重新启动了RStudio并尝试通过键入
来安装RMySQL
install.packages('RMySQL',type='source')
软件包已正确下载,但在安装时发出了大量警告和错误。我在这里粘贴它们。
Installing package into ‘C:/Users/.../Documents/R/win-library/3.0’
(as ‘lib’ is unspecified)
trying URL 'http://cran.rstudio.com/src/contrib/RMySQL_0.9-3.tar.gz'
Content type 'application/x-gzip' length 165363 bytes (161 Kb)
opened URL
downloaded 161 Kb
* installing *source* package 'RMySQL' ...
** package 'RMySQL' successfully unpacked and MD5 sums checked
checking for $MYSQL_HOME... C:\Program Files\MySQL\MySQL Server 5.6
cygwin warning:
MS-DOS style path detected: C:\Program
Preferred POSIX equivalent is: /cygdrive/c/Program
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
test: Files\MySQL\MySQL: unknown operand
** libs
Warning: this package has a non-empty 'configure.win' file,
so building only the main architecture
cygwin warning:
MS-DOS style path detected: C:/PROGRA~1/R/R-30~1.3/etc/x64/Makeconf
Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-30~1.3/etc/x64/Makeconf
CYGWIN environment variable option "nodosfilewarning" turns off this warning.
Consult the user's guide for more details about POSIX paths:
http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
gcc -m64 -I"C:/PROGRA~1/R/R-30~1.3/include" -DNDEBUG -I"C:\Program Files\MySQL\MySQL Server 5.6"/include -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -std=gnu99 -mtune=core2 -c RS-DBI.c -o RS-DBI.o
RS-DBI.c: In function 'RS_na_set':
RS-DBI.c:1219:11: warning: variable 'c' set but not used [-Wunused-but-set-variable]
gcc -m64 -I"C:/PROGRA~1/R/R-30~1.3/include" -DNDEBUG -I"C:\Program Files\MySQL\MySQL Server 5.6"/include -I"d:/RCompile/CRANpkg/extralibs64/local/include" -O2 -Wall -std=gnu99 -mtune=core2 -c RS-MySQL.c -o RS-MySQL.o
RS-MySQL.c: In function 'RS_MySQL_fetch':
RS-MySQL.c:657:13: warning: variable 'fld_nullOk' set but not used [-Wunused-but-set-variable]
RS-MySQL.c: In function 'RS_DBI_invokeBeginGroup':
RS-MySQL.c:1137:30: warning: variable 'val' set but not used [-Wunused-but-set-variable]
RS-MySQL.c: In function 'RS_DBI_invokeNewRecord':
RS-MySQL.c:1158:20: warning: variable 'val' set but not used [-Wunused-but-set-variable]
RS-MySQL.c: In function 'RS_MySQL_dbApply':
RS-MySQL.c:1219:38: warning: variable 'fld_nullOk' set but not used [-Wunused-but-set-variable]
gcc -m64 -shared -s -static-libgcc -o RMySQL.dll tmp.def RS-DBI.o RS-MySQL.o C:\Program Files\MySQL\MySQL Server 5.6/bin/libmySQL.dll -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-30~1.3/bin/x64 -lR
gcc.exe: error: C:\Program Files\MySQL\MySQL Server 5.6/bin/libmySQL.dll: No such file or directory
ERROR: compilation failed for package 'RMySQL'
* removing 'C:/Users/.../Documents/R/win-library/3.0/RMySQL'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-30~1.3/bin/x64/R" CMD INSTALL -l "C:\Users\...\Documents\R\win-library\3.0" C:\Users\..~1\AppData\Local\Temp\RtmpcdXPKB/downloaded_packages/RMySQL_0.9-3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘RMySQL’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\...\AppData\Local\Temp\RtmpcdXPKB\downloaded_packages’
在我的R控制台中,我通过输入打印MYSQL_HOME
Sys.getenv('MYSQL_HOME')
来仔细检查我的[1] "C:\\Program Files\\MySQL\\MySQL Server 5.6"
设置是否正确
我该如何解决这些错误?
答案 0 :(得分:1)
有效。我所要做的就是将libmysql.dll
文件从我的MySQL安装目录的lib
文件夹复制到bin
文件夹中。
在此之后,install.packages('RMySQL',type='source')
命令工作正常。
This链接有帮助。