Installing RMySQL under Windows

Connecting R with MySQL can be somewhat difficult using Windows. The package RMySQL is not available as a precompiled zip-archive. It needs the installed libmysqll.dll library to be working and must therefore be compiled on your machine. Linux and Mac OSX have compilers build-in, Windows does not. This tutorial shows how to install RMySQL under Windows and givew some hints how to avoid too much extra work then updating R.

Step 1: Requirements

  • R (surprise! :-) )
  • RTools (compiling environment for Windows)
  • MySQL-Server (normally the community edition)

Step 2: Setup and Configuring

I assume that you already have an installed R and the MySQL-Server. This tutorial uses a 64-bit-system (which you also may have nowadays, though). The next step is to install RTools. The offered install options are fine, additional libraries like TCL/TK etc. are maybe needed if you want to compile packages who need them.

RTools Step 1

The next window is really arkward. Just leave the the two checkboxes checked and move on to the next step.

RTools Step 2

Editing the System Path is important and tells R where the compiler is located. There should be four entries. Please be aware when updating RTools: This sometimes causes double entries (can be deleted).

RTools Step 3

Step 3: Tell Windows where the MySQL-Libraries are

RMySQL needs the libmysql.dll to compile successfully. The file should be stored in lib-Folder of your MySQL installation. Usually the path should be C:\Program Files\MySQL\MySQL Server 5.5\. The problem is that RMySQL expect it to be stored in the bin-Folder. So you have to copy it by hand.

Telling R where to find the libraries can be done by three different options: Command line, environment file (.Renviron) or environment variables. Using command line options must be passed to R at every start which makes it complicated to use IDEs like Rstudio. Using the enviroment file is easier but you have to copy it into every new installation/update of R (which also requires writing rights). I suggest using environment variables as this causes no problems/extra work – espacially when updating R.

Your environment variables are located under Control PanelUser AccuntsChange my environment variables. My environment variables look like this (the window is in German as you might have noticed ;-) ). Now you can add a new variable called MYSQL_HOME with the value C:\Program Files\MySQL\MySQL Server 5.5.
My installed packages are located at C:\myRLib using the variable R_LIBS (this is optional).

Environment Variables

Step 4: Compiling

Now restart R if you have already opened it and install RMySQL from source:
install.packages(“RMySQL”, type = “source”)
Your output should look like this. I truncated all warnings which could usually be ignored.

> install.packages("RMySQL", type = "source")
Warning in install.packages :
  package ‘RMySQL’ is not available (for R version 3.0.1)
trying URL 'http://ftp5.gwdg.de/pub/misc/cran/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' ...
** Paket 'RMySQL' erfolgreich entpackt und MD5 Summen überprüft
checking for $MYSQL_HOME... C:\Program Files\MySQL\MySQL Server 5.5
** libs
gcc -m64 -I"C:/PROGRA~1/R/R-30~1.1/include" -DNDEBUG -I"C:\Program Files\MySQL\MySQL Server 5.5"/include    -I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c RS-DBI.c -o RS-DBI.o
gcc -m64 -I"C:/PROGRA~1/R/R-30~1.1/include" -DNDEBUG -I"C:\Program Files\MySQL\MySQL Server 5.5"/include    -I"d:/RCompile/CRANpkg/extralibs64/local/include"     -O2 -Wall  -std=gnu99 -mtune=core2 -c RS-MySQL.c -o RS-MySQL.o
gcc -m64 -shared -s -static-libgcc -o RMySQL.dll tmp.def RS-DBI.o RS-MySQL.o C:\Program Files\MySQL\MySQL Server 5.5/bin/libmySQL.dll -Ld:/RCompile/CRANpkg/extralibs64/local/lib/x64 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-30~1.1/bin/x64 -lR
installing to c:/myRLib/RMySQL/libs/x64
** R
** inst
** preparing package for lazy loading
Creating a generic function for 'format' from package 'base' in package 'RMySQL'
Creating a generic function for 'print' from package 'base' in package 'RMySQL'
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
MYSQL_HOME defined as C:\Program Files\MySQL\MySQL Server 5.5 
* DONE (RMySQL)

No you can load your new packages and access your local MySQL-Server.

library(RMySQL)
con <- dbConnect(MySQL(), host="127.0.0.1", port= 3306, user="user",
   password = "password", dbname="db")

I hope this will help someone installing RMySQL properly. If not, please leave a comment…

Dieser Beitrag wurde unter R abgelegt und mit , , , verschlagwortet. Setze ein Lesezeichen auf den Permalink.

42 Antworten auf Installing RMySQL under Windows

  1. Pingback: the weg of installation of RMySQL | ninggg

  2. AYUSH RAJ SINGH sagt:

    I am getting an error. Please help me resolve it. Thanks a lot.

    > 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’

  3. Sepideh sagt:

    Hi, so many thanks to you. that helped me greatly :-)

  4. willem sagt:

    Took me ages to work this out, but your post really helped
    I had to do one more thing:
    Copy libmysql.dll from ../MySQL Server 5.6/lib to ../MySQL Server 5.6/bin

  5. Catherine sagt:

    Hmmmmmm!!!You saved me alot Arne and Willem. Thank you, it worked like charm.

    • yuanzhikai sagt:

      How did you solve this problem at last ? I got the same problem .Help ! I did all the steps he said but still can’t work .

  6. Antoine sagt:

    Thank you for the detailed process: helps a lot!
    I still get the following error though (Windows 8.1 64 bits).

    gcc -m64 -I”C:/PROGRA~1/R/R-30~1.3/include” -DNDEBUG -I”C:Program FilesMySQLMySQL 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
    In file included from RS-MySQL.c:22:0:
    RS-MySQL.h:32:19: fatal error: mysql.h: No such file or directory

    I checked Makevars.win64 source file: PKG_CPPFLAGS is defined to -I”${MYSQL_HOME}”/include where the file mysql.h does actually exists! How come RMySQL installer cannot find it? I also tried installing from Administrator account and got the same error so it does not seem related to the user’s rights. Any idea?

    • Jim Smith sagt:

      I have the same error with “RS-MySQL.h:32:19: fatal error: mysql.h: No such file or directory”. I don’t understand your slash fix. I have;
      Variable name: MYSQL_HOME
      Variable value: c:\Program Files\MySQL\MySQL Server 5.1

      What slash should be changed?
      Thanks,
      Jim

      • Jim Smith sagt:

        My problem was that I had mysql 5.1 and there really wasn’t a mysql.h file. Upgraded to mysql 5.6.
        I had to copy libmysql.dll to the bin directory as it appears to have moved from mysql 5.5.

        Thanks,
        Jim

  7. Antoine sagt:

    My bad: MYSQL_HOME was defined with antislash instead of slash which causes the problem.

  8. Bernard sagt:

    This is fantastic, it works like magic, thanks so much

  9. Senem sagt:

    When I try to compile RMySQL as described in the README inside RMySQL.tar.gz, I get a non-descriptive message saying “The system cannot find the path specified”. Has anyone encountered this? (I set the environment variables for MYSQL_HOME and R_LIB)

    Also I can’t find libmysql.dll under any of MySQL installation directories. (I installed MySQL 5.6)

  10. Alan sagt:

    Thank you VERY much for this great tutorial.

  11. Marta sagt:

    Arne,
    A very big “THANK YOU!” for this post! It saved me a lot of time and nerves, too.

  12. Arne sagt:

    @Semen: Have you installed RTools? And not having libmysql.dll sound strange. Have you tried to reinstall MySQL-Server?

  13. Rnoob sagt:

    Many thanks for this instructions. I initially had some difficulties with the execution of install.packages(“RMySQL”, type = “source”).

    Inside the R response mesage there was a part that said something like:
    “$MYSQL_HOME … not found … ”

    I restarted my computer an reran the command and it worked. Thanks again.

  14. Godot sagt:

    Little trick :
    An error (I always do :( )… and it seems like I’m not the only one :
    I put a “\” at the end of the path of the variable MYSQL_HOME.
    This prevent the concatenation with /include that is done in the gcc command…
    “C:\Program Files\MySQL\MySQL Server 5.6\”/include

  15. Joana Salvado sagt:

    Hello there! First thank you for your post, it is very helpfull! But still I’m getting a nasty error:

    ** testing if installed package can be loaded
    Error : .onLoad failed in loadNamespace() for ‘RMySQL’, details:
    call: utils::readRegistry(“SOFTWARE\\MySQL AB”, hive = “HLM”, maxdepth = 2)
    error: Registry key ‘SOFTWARE\MySQL AB’ not found
    Error: loading failed
    Execution halted
    ERROR: loading failed
    * removing ‘C:/Users/Yohanan/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\Yohanan\Documents\R\win-library\3.0″ C:\Users\Yohanan\AppData\Local\Temp\RtmpYjrEyD/downloaded_packages/RMySQL_0.9-3.tar.gz’ had status 1
    Warning in install.packages :
    installation of package ‘RMySQL’ had non-zero exit status

    I’m searched for it online and I’m not seeing any solutions just posted questions…Do you have any clues why this is happening?

    I have a Windows 8.1 machine, RTools 30 and R 3.0.3.

    • Arne sagt:

      Hi Joana,
      the problem is your MySQL installation. The error says:
      call: utils::readRegistry(“SOFTWARE\\MySQL AB”, hive = “HLM”, maxdepth = 2)
      error: Registry key ‘SOFTWARE\MySQL AB’ not found
      That means that R can’t find the MySQL information within the Windows registry. Can you find them manually? Hit the [Windows]-Key and type “regedit” and search for “MySQL AB” in HKEY_URRENT_USER\SOFTWARE or HKEY_LOCAL_MACHINE\SOFTWARE.

      • sharang sagt:

        Arne and Joana,

        I have the same problem. Arne: I found MySQL AB in HKEY_CURRENT_USER\SOFTWARE though. How do I proceed?

        Thanks

  16. Monika sagt:

    Thanks a lot, really helpful! I had to additionally create a subfolder “opt” in the “MySQL Server 5.6\lib” folder and copy the “libmysql.lib” file in there but then it worked perfectly. Thanks again!

  17. Kidambiv sagt:

    Hi – thanks for your post! I followed the instructions and still ran into a “configuration” error. I have a Windows 7, R 3.0.3, MySql Server 5.6, and latest RTools installed. I have copied the libmysql.dll to my bin folder and created the environment variables as instructed. Here’s my log during installation which ended with the following “ERROR: configuration failed for package ‘RMySQL’”. Request your help.
    —————————————————————————

    — Please select a CRAN mirror for use in this session —
    also installing the dependency ‘DBI’

    trying URL ‘http://ftp.iitm.ac.in/cran/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://ftp.iitm.ac.in/cran/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
    Warning: running command ‘sh ./configure.win’ had status 127
    ERROR: configuration failed for package ‘RMySQL’
    * removing ‘C:/Users/KidambiV/Documents/R/win-library/3.0/RMySQL’

    The downloaded source packages are in
    ‘C:\Users\KidambiV\AppData\Local\Temp\RtmpQfrtry\downloaded_packages’
    Warning messages:
    1: running command ‘”C:/PROGRA~1/R/R-30~1.3/bin/i386/R” CMD INSTALL -l “C:\Users\KidambiV\Documents\R\win-library\3.0″ C:\Users\KidambiV\AppData\Local\Temp\RtmpQfrtry/downloaded_packages/RMySQL_0.9-3.tar.gz’ had status 1
    2: In install.packages(“RMySQL”, type = “source”) :
    installation of package ‘RMySQL’ had non-zero exit status

  18. Kidambiv sagt:

    Hello – Just a follow-up update. I re-installed the RTools again (had a feeling I didn’t do it right the first time). This time i ran into a different error some of the folks had already faced. It tried looking for the libmySQL.dll in OPT folder. So I created them and re-ran. Still didn’t work. but then now I tried with R 64bit version and it worked. However when I tried it on the R 32bit it continues to fail with the below error. When I try to load the library via RStudio it seems to work. Does it even matter now to go thru this 32 bit installation? If so, I am more confused than before! :( please help!

    * 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/i386/Makeconf
    Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-30~1.3/etc/i386/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 -m32 -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” -O3 -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 -m32 -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” -O3 -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 -m32 -shared -s -static-libgcc -o RMySQL.dll tmp.def RS-DBI.o RS-MySQL.o C:\Program Files\MySQL\MySQL Server 5.6/lib/opt/libmysql.lib -Ld:/RCompile/CRANpkg/extralibs64/local/lib/i386 -Ld:/RCompile/CRANpkg/extralibs64/local/lib -LC:/PROGRA~1/R/R-30~1.3/bin/i386 -lR
    RS-MySQL.o:RS-MySQL.c:(.text+0xb8): undefined reference to `mysql_more_results@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0×348): undefined reference to `mysql_init@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0×365): undefined reference to `mysql_options@12′
    RS-MySQL.o:RS-MySQL.c:(.text+0×383): undefined reference to `mysql_options@12′
    RS-MySQL.o:RS-MySQL.c:(.text+0x3a1): undefined reference to `mysql_options@12′
    RS-MySQL.o:RS-MySQL.c:(.text+0x3dc): undefined reference to `mysql_real_connect@32′
    RS-MySQL.o:RS-MySQL.c:(.text+0×448): undefined reference to `mysql_close@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x47d): undefined reference to `mysql_error@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0×839): undefined reference to `mysql_close@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x8af): undefined reference to `mysql_fetch_fields@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x8c9): undefined reference to `mysql_field_count@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xbb6): undefined reference to `mysql_next_result@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xbe0): undefined reference to `mysql_use_result@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xbed): undefined reference to `mysql_field_count@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xcdb): undefined reference to `mysql_affected_rows@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xd97): undefined reference to `mysql_fetch_row@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xdaa): undefined reference to `mysql_free_result@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xdfd): undefined reference to `mysql_query@8′
    RS-MySQL.o:RS-MySQL.c:(.text+0xe10): undefined reference to `mysql_use_result@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xe1d): undefined reference to `mysql_field_count@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xebd): undefined reference to `mysql_error@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0xf58): undefined reference to `mysql_affected_rows@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0×1088): undefined reference to `mysql_fetch_row@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x10a1): undefined reference to `mysql_fetch_lengths@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x12a7): undefined reference to `mysql_errno@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x142b): undefined reference to `mysql_errno@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0×1439): undefined reference to `mysql_error@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x14b6): undefined reference to `mysql_fetch_row@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x14c5): undefined reference to `mysql_free_result@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x16de): undefined reference to `mysql_get_client_info@0′
    RS-MySQL.o:RS-MySQL.c:(.text+0x18d4): undefined reference to `mysql_get_host_info@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x18fe): undefined reference to `mysql_get_server_info@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x192b): undefined reference to `mysql_get_proto_info@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x193c): undefined reference to `mysql_thread_id@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0×2588): undefined reference to `mysql_fetch_row@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x25b5): undefined reference to `mysql_errno@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x26d8): undefined reference to `mysql_fetch_lengths@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x2cd3): undefined reference to `mysql_insert_id@4′
    RS-MySQL.o:RS-MySQL.c:(.text+0x2dbb): undefined reference to `mysql_real_escape_string@16′
    RS-MySQL.o:RS-MySQL.c:(.text+0x2e84): undefined reference to `mysql_get_client_info@0′
    RS-MySQL.o:RS-MySQL.c:(.text+0x2eca): undefined reference to `mysql_get_client_version@0′
    RS-MySQL.o:RS-MySQL.c:(.text+0x2f1b): undefined reference to `mysql_server_init@12′
    RS-MySQL.o:RS-MySQL.c:(.text+0x2f23): undefined reference to `mysql_get_client_version@0′
    RS-MySQL.o:RS-MySQL.c:(.text+0x2f44): undefined reference to `mysql_get_client_info@0′
    RS-MySQL.o:RS-MySQL.c:(.text+0x2f71): undefined reference to `mysql_server_end@0′
    collect2: ld returned 1 exit status
    ERROR: compilation failed for package ‘RMySQL’
    * removing ‘C:/Users/KidambiV/Documents/R/win-library/3.0/RMySQL’
    * restoring previous ‘C:/Users/KidambiV/Documents/R/win-library/3.0/RMySQL’
    Warning in file.copy(lp, dirname(pkgdir), recursive = TRUE) :
    problem copying C:\Users\KidambiV\Documents\R\win-library\3.00LOCK-RMySQL\RMySQL\libs\x64\RMySQL.dll to C:\Users\KidambiV\Documents\R\win-library\3.0\RMySQL\libs\x64\RMySQL.dll: Permission denied

    The downloaded source packages are in
    ‘C:\Users\KidambiV\AppData\Local\Temp\RtmpUDdqkG\downloaded_packages’
    Warning messages:
    1: In open.connection(con, “r”) :
    unable to connect to ‘cran.r-project.org’ on port 80.
    2: running command ‘”C:/PROGRA~1/R/R-30~1.3/bin/i386/R” CMD INSTALL -l “C:\Users\KidambiV\Documents\R\win-library\3.0″ C:\Users\KidambiV\AppData\Local\Temp\RtmpUDdqkG/downloaded_packages/RMySQL_0.9-3.tar.gz’ had status 1
    3: In install.packages(“RMySQL”, type = “source”) :
    installation of package ‘RMySQL’ had non-zero exit status

  19. Alan sagt:

    Hello, Thanks for all help!
    I have the following error;
    “Error in i$Location : $ operator is invalid for atomic vectors
    Calls: lapply -> FUN -> file.path
    Execution halted

    Warning: running command ‘sh ./configure.win’ had status 1
    ERROR: configuration failed for package ‘RMySQL’

    Please help me on this issue. Thank you again.

  20. Alan sagt:

    Regarding my question above, the error occurred while installing the RMySQL. For more reference, I copy the whole response from the system below. It happened when I was installing the RMySQL;

    Installing package into ‘C:/Users/seom/Documents/R/win-library/3.1’
    (as ‘lib’ is unspecified)
    * installing *source* package ‘RMySQL’ …
    ** package ‘RMySQL’ successfully unpacked and MD5 sums checked
    checking for $MYSQL_HOME… not found… searching registry…

    cygwin warning:
    MS-DOS style path detected: C:/PROGRA~1/R/R-31~1.0/bin/i386/Rscript
    Preferred POSIX equivalent is: /cygdrive/c/PROGRA~1/R/R-31~1.0/bin/i386/Rscript
    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
    Try setting MYSQL_HOME to one of the following (you may have to use the non-8dot3 file name):

    Error in i$Location : $ operator is invalid for atomic vectors
    Calls: lapply -> FUN -> file.path
    Execution halted

    Warning: running command ‘sh ./configure.win’ had status 1
    ERROR: configuration failed for package ‘RMySQL’
    * removing ‘C:/Users/seom/Documents/R/win-library/3.1/RMySQL’
    Warning in install.packages :
    running command ‘”C:/PROGRA~1/R/R-31~1.0/bin/i386/R” CMD INSTALL -l “C:\Users\seom\Documents\R\win-library\3.1″ “C:/Users/seom/Downloads/RMySQL_0.9-3.tar.gz”‘ had status 1
    Warning in install.packages :
    installation of package ‘C:/Users/seom/Downloads/RMySQL_0.9-3.tar.gz’ had non-zero exit status

  21. Alan sagt:

    Dear Arne,
    I tried to follow all instructions. But where are you specifically pointing to set $MYSQL_HOME? Is it inside R? Can you please tell me a little more in detail? I am a total novice in MySQL / R world.
    I really appreciate!

    Best,
    Alan

  22. Alan sagt:

    I have one more question. I found one potential answer below. However, I have no idea how I can edit the tar.gz file or what ” installed by running install.packages on the locally modified tarball.” means. Can anyone help me out?

    Thank you very much.

    There is a mismatch between the nature of the registry for the latest version of MySQL and the code in the package.

    Within the tar.gz file, there is an R file “\RMySQL_0.9-3.tar\RMySQL\R\zzz.R” which contains the following code:

    # check registry
    if (!dir.exists(mysql)) {
    reg <- utils::readRegistry("SOFTWARE\\MySQL AB", hive="HLM", maxdepth=2)
    for (i in reg){
    mysql <- i$Location
    if (dir.exists(mysql)) {
    if (verbose) cat(mysql, "found in registry\n")
    break
    }
    }
    }
    It used to be the case that each element of "reg" was a list, but the first element is now a vector. This means that the "mysql <- i$Location" statement will fail, creating the error message you observe.

    I modified the statement to skip the first element of the registry by changing the line

    for (i in reg){
    to

    for (i in reg[-1]){
    and installed by running install.packages on the locally modified tarball.

  23. Alan sagt:

    Dear Arne,
    I found that in my setting my MYSQL_Home, I had “/” at the end, which caused all the problem. It is now resolved.
    Thank you for your help.

    Alan.

  24. Mark sagt:

    Thank you for the help, trying all of the above but getting the following everytime:
    * installing *source* package ‘RMySQL’ …
    ** package ‘RMySQL’ successfully unpacked and MD5 sums checked
    Warning: running command ‘sh ./configure.win’ had status 127
    ERROR: configuration failed for package ‘RMySQL’
    * removing ‘C:/Users/me/Desktop/Documents/R/win-library/3.0/RMySQL’

    The downloaded source packages are in
    ‘C:\Users\me\AppData\Local\Temp\RtmpgJhvub\downloaded_packages’
    Warning messages:
    1: running command ‘”C:/PROGRA~1/R/R-30~1.3/bin/x64/R” CMD INSTALL -l “C:\Users\me\Desktop\Documents\R\win-library\3.0″ C:\Users\me\AppData\Local\Temp\RtmpgJhvub/downloaded_packages/RMySQL_0.9-3.tar.gz’ had status 1
    2: In install.packages(“RMySQL”, type = “source”) :
    installation of package ‘RMySQL’ had non-zero exit status

    Thank you for any thoughts!

  25. Mark sagt:

    Sorry all, never mind, silly syntax error on my part, looks like it worked. thanks!

  26. Paul sagt:

    here’s how I got the RMysql to build

    # Copy dll from lib to bin folder by hand (might get error because this folder requires admin permissions but
    # botttom line, find a way to get libmysql.dll into the bin folder
    file.copy(“C:/Program Files/MySQL/MySQL Server 5.7/lib/libmysql.dll”, “C:/Program Files/MySQL/MySQL Server 5.7/bin”)

    # set MYSQL_HOME environment variable
    Sys.setenv(MYSQL_HOME = “C:/Program Files/MySQL/MySQL Server 5.7″)
    Sys.getenv(“MYSQL_HOME”)

    # Now install RMysql
    install.packages(“RMySQL”, type = “source”)

  27. CheYuriy sagt:

    Killed 2 hours to install it. But succeed. Created a little memo: https://gist.github.com/cheyuriy/6f78d83570f6d737c176

    • yuanzhikai sagt:

      why not MYSQL_HOME = “C:/Program Files/MySQL/MySQL Server 5.6″ ?

      • CheYuriy sagt:

        Don’t need to install whole server for this purpose. C Connectors will be enough. But its your choice – just make sure that your server installation includes necessary libraries and headers (maybe you need to start installation wizard once again and check them)

  28. Frank Hasbani sagt:

    Hi:

    I am using Win7-64 pro, Version 0.98.953 – © 2009-2013 RStudio, and R version 3.1.1 (2014-07-10)

    I got a warning upon install that mySql 6.1.5 is the loading app. But all successfuly compiled.
    I uninstalled and re-installed 5.5.38, but the same message presisted.
    I am getting the same when I :

    library(“RMySQL”, lib.loc=”C:/Program Files/R/R-3.1.1/library”)
    Loading required package: DBI
    MYSQL_HOME defined as C:/Program Files/MySQL/MySQL Server 5.5
    Warning message:
    In inDL(x, as.logical(local), as.logical(now), …) :

    RMySQL was compiled with MySQL 5.5.38 but loading MySQL 6.1.5 instead!
    This may cause problems with your database connections.

    Please install MySQL 5.5.38.

    If you have already done so, you may need to set your environment
    variable MYSQL_HOME to the proper install directory.
    >

    Any ideas as to what is causing this and how can I fix it?

    Any help is much appreciated

Hinterlasse eine Antwort

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind markiert *


neun + 4 =

Du kannst folgende HTML-Tags benutzen: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>