简体   繁体   中英

How to install RMySQL package for Windows?

Since binary file of RMySQL package is not available, I am not able to install it on Windows.

I looked up internet. I found this link. http://www.ahschulz.de/2013/07/23/installing-rmysql-under-windows/comment-page-1/#comment-3123

I followed the instructions, but I am getting an ERROR.

This is the final output I get after

>install.packages('RMySQL',type='source')

Installing package into 'C:/Users/admin/Documents/R/win-library/3.0' (as 'lib' is unspecified) also installing the dependency 'DBI'

trying URL ' http://cran.rstudio.com/src/contrib/DBI_0.2-7.tar.gz ' Content type 'application/x-gzip' length 194699 bytes (190 Kb) opened URL downloaded 190 Kb

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 'DBI' ... package 'DBI' successfully unpacked and MD5 sums checked R inst preparing package for lazy loading Creating a generic function for 'summary' from package 'base' in package 'DBI' help installing help indices building package indices installing vignettes testing if installed package can be loaded arch - i386 arch - x64 DONE (DBI)

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.1/etc/x64/Makeconf Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-30~1.1/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.1/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

* *Syntax error: Unterminated quoted string make: [RS-DBI.o] Error 2 ERROR: compilation failed for package 'RMySQL' ***

  • removing 'C:/Users/admin/Documents/R/win-library/3.0/RMySQL' Warning in install.packages : running command '"C:/PROGRA~1/R/R-30~1.1/bin/x64/R" CMD INSTALL -l "C:\\Users\\admin\\Documents\\R\\win-library\\3.0" C:\\Users\\admin\\AppData\\Local\\Temp\\RtmpMvp14B/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\\admin\\AppData\\Local\\Temp\\RtmpMvp14B\\downloaded_packages'

I have written the error i am getting in bold. Please help me resolve it. Thanks a lot.

  • Go to System->Advanced->Enviroment Variables, press New and Enter Variable name as MYSQL_HOME and Variable values as C:/Program Files/MySQL/MySQL Server 5.6/ , and notice that it is "/" not "\\"
  • Copy C:/Program Files/MySQL/MySQL Server 5.6/lib/libmysql.dll to C:/Program Files/MySQL/MySQL Server 5.6/bin and create C:/Program Files/MySQL/MySQL Server 5.6/lib/opt folder and copy C:/Program Files/MySQL/MySQL Server 5.6/lib/libmysql.lib to the opt folder
  • Run install.packages('RMySQL',type='source')

In some instances you might need to restart your PC.

Please following the instruction here: http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL I believe you missed the step 3

3. Edit or create the file Renviron.site and add the variable MYSQL_HOME which contains the location of your MySQL install. The file typically isn't created when installing R, so you may need to create it yourself. You will want to place it under the /etc directory in your R Home area. If you don't know where that is, you can issue R.home() at your R prompt. You will be adding a variable named MYSQL_HOME in variable=value syntax.

Here's an example:

Location of Renviron.site: C:/PROGRA~1/R/R-2.11~1.0/etc/Renviron.site 
Content is: MYSQL_HOME=C:/PROGRA~1/MySQL/MYSQLS~1.0/

I had this same issue as well. It took me a while to understand:

  1. that I needed to manually create a text file named Renviron.site in the proper Windows directory, and,

  2. that the manually created Renviron.site file needed to contain the definition of the MYSQL_HOME variable.

Here is my example from Windows 10 and R version 3.2.2:

  1. I issued the command R.home() at the R prompt in R Studio:

     R.home() [1] "C:/PROGRA~1/R/R-32~1.2" 
  2. With that information, I navigated to the etc folder in Windows:

      C:\\Program Files\\R\\R-3.2.2\\etc 
  3. I placed a manually created text file called Renviron.site within this directory (the "etc" folder). The only data in the Renviron.site text file is the following:

     MYSQL_HOME=C:/PROGRA~1/MySQL/MYSQLS~1.2/ 

    (I wasn't sure whether to use ~1.0 or ~1.2 here based on the output from the R.home() command in R, but, this seemed to work)

  4. Once the file was saved, I restarted R and I was able to install the RMySQL package in R.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM