adding RMySQL package to R fails (on Windows)?

后端 未结 11 2308
予麋鹿
予麋鹿 2020-11-30 06:03

I can\'t figure out why my RMySQL package won\'t install - here\'s what I get:

> install.packages(\'RMySQL\',type=\'source\')
trying URL \'http://cran.mir         


        
相关标签:
11条回答
  • 2020-11-30 06:41

    The basic process is described here, but there are several hints, So I will describe the whole solution (please change the R version and paths if needed):

    1. Install latest RTools from here
    2. install MySQL or header and library files of mysql
    3. create or edit file C:\Program Files\R\R-2.12.1\etc\Renviron.site and add line like MYSQL_HOME=C:/mysql (path to your mysql files)
    4. copy libmysql.lib from mysql/lib to mysql/lib/opt to meet dependencies.
    5. copy libmysql.dll to C:\Program Files\R\R-2.12.1\bin or to windows/system32 directory.
    6. run install.packages('RMySQL',type='source') and wait while compilation will end.

    This worked for me on Windows 7 64 bit, so there should be no problems with 32 bit versions

    Initialy posted here (similar question).

    0 讨论(0)
  • 2020-11-30 06:43

    I was working for last 2 days on Installation of R with RMySQL package, finally got the solution for that, here are the steps to install RMySQL package:-

    1. DOWNLOAD SOFTWARE FROM THE FOLLOWING LINKS: *a. R2.13.2: Download R from http://cran.stat.sfu.ca/index.html

        b. RTools 214:  Download RTools from http://cran.cict.fr
      
        c. RMySQL 0.8-0.tar.gz: Download RMySQL from 
        http://biostat.mc.vanderbilt.edu/wiki/main/RMySQL/RMySQL_0.8-0.tar.gz
      
        d. MySQL Server 5.0: download it from http://dev.mysql.com
      
        e. RSTUDIO (optional): download it from http://rstudio.org*
      
    2. SET THE FOLLOWING ENVIRONMENT VARIABLES

       * a. MYSQL_HOME : <drive>/path to MySQL installation folder
            e.g. MYSQL_HOME= C:\Program Files\MySQL\MySQL Server 5.5\ 
      
        b. R_HOME: <drive>/path to R installation
           e.g. R_HOME=C:\Program Files\R\R-2.13.2\
      
        c. PATH: Modify path to accommodate the above variables. *
      

      Be sure that the following paths areincluded in your Windows PATH variable: \Rtools\2.14\bin \Rtools\2.14\MinGW\bin \Rtools\2.14\MinGW64\bin

    3. CREATE FOLDER AND COPY FILES

      a. OPT: Create a folder OPT under C:\Program Files\MySQL\MySQL Server 5.5\lib and copy
      MYSQLLIB.LIB the above path. Also copy libmysql.dll to \\R\R-2.14.0\bin\ (64 bit) Or \\R\R-2.14.0\bin\i386\ (32 bit) and to C:\Windows\System32.

    b. Renviron.site: create or edit a file \\R\R-2.14.0\etc\Renviron.site and add a line: MYSQL_HOME =”C:/Program Files/MySQL/MySQL Server 5.5/” NB: USE FORWARD SLASH AND DOUBLE QUOTES HERE

    c. libMySQL.dll: Copy this file to C:\Program Files\R\R-2.13.2\bin\i386 as well as C:\Program Files\R\R-2.13.2\bin

    1. RUN COMMANDS

      a. Install.Packages: Run R GUI by clicking on the R icon on desktop or from Start menu. Type INSTALL.PACKAGES(“RMySQL”,type=”Sources”). This will download the required software from repositories.

    b. Command Prompt: Copy the downloaded zip file (in step 4.a.) and paste it under R installation folder. Go to start menu and open Command Prompt. Go to the R installation folder and type R CMD INSTALL RMySQL_0.8-0.tar.gz

      *COMMANDS:
      >library(RMySQL)
       >drv = dbDriver("MySQL")
       >con = dbConnect(drv,host="localhost",dbname="test",user="root",pass="root")
       >album = dbGetQuery(con,statement="select * from t_master")
       >album*
    
    0 讨论(0)
  • 2020-11-30 06:43

    18 months later, new laptop, same problem. Returning to the scene of the crime - sorry January 2011 self; we're in the future, and this installation still isn't any fun.

    Lessons learned:

    -Updated RTools are essential. Get them.

    -Are you seeing an error along the lines of .onLoad failed in loadNamespace() for 'RMySQL', details? This seems to mean that there's a problem with your system environment variables.

    In R, run

    Sys.getenv('MYSQL_HOME')
    

    If it spits back a path like

     [1] "C:\\Program Files\\MySQL\\MySQL Server 5.6"
    

    you're good. But if it gives you empty string, you need to set this.

    These are all Windows 7 directions, but the process is pretty similar in XP, if memory serves.

    1) Bring up System Properties > Advanced > Environment Variables.

    2) In the lower 'System Variables' pane, click 'New'.

    3) Variable name is MYSQL_HOME and value is whatever the path is to your MySQL installation - mine was C:\Program Files\MySQL\MySQL Server 5.6

    Newer versions of MySQL don't seem to create an environment variable on install - that and the lack of binaries for RMySQL explain why this questions has garnered 8,000 hits.

    -Still stuck? Here are two additional in-depth writeups: 1, 2

    0 讨论(0)
  • 2020-11-30 06:48

    First I would try following the directions on this page: http://biostat.mc.vanderbilt.edu/wiki/Main/RMySQL

    Then, ensure that you actually have a MySQL client on your computer, not just the server itself. I've had a problem myself where I had to use an older binary for the client, but you can download these from mysql website.

    0 讨论(0)
  • 2020-11-30 06:50

    I created a binary which might work for people:

    http://kenahoo.blogspot.com/2011/09/rmysql-binary-for-windows-7.html

    I basically followed all these directions, including the ones at the Vanderbilt page, but for one reason or another it doesn't always seem to work. Anyway, hope this might be helpful for people who have the same versions of stuff I used.

    0 讨论(0)
  • 2020-11-30 06:50

    Add MySQL and RTools directory to the PATH!

    Here is my PATH ; ~blah~;C:\Program Files\MySQL\MySQL Server 5.5\bin;c:\rtools\bin;C:\Rtools\gcc-4.6.3\bin;

    0 讨论(0)
提交回复
热议问题