Using MySQL with the R in the RMySQL package

3

I'm new to MySQL and I installed this program to use with R. I was able to install the RMySQL library, following the tutorials I found on the internet and the course I'm doing at Coursera as

link and

link

I even tried to install an older RMySQL second library: link

Using the code:

require(devtools)

install_version("RMySQL", version = "0.10.9", repos = "http://cran.us.r-
project.org")

But none of this worked. When I went to test MySQL, connecting to MySQL from UCLA using the following command:

ucscDb <- dbConnect(MySQL(), user="genome", host="genome-mysql.cse.ucsc.edu")

The following error appeared:

Error in .local(drv, ...) : 
Failed to connect to database: Error: Lost connection to MySQL server at 
'reading authorization packet', system error: 10060

I believe this happened because of problems installing MySQL. Does anyone have any tips or suggestions?

    
asked by anonymous 02.06.2017 / 21:18

1 answer

1

The easiest method to install RMySQL in R for Windows is via install.packages .

Do the following:

Step 1: Normal R installation for Windows link

Step 2: Open the R environment and install the latest version of RMySQL directly from CRAN:

> install.packages("RMySQL", repos="http://cran.r-project.org")
Warning in install.packages("RMySQL", repos = "http://cran.r-project.org") :
  'lib = "C:/Program Files/R/R-3.4.0/library"' is not writable
also installing the dependency ‘DBI’

tentando a URL 'http://cran.r-project.org/bin/windows/contrib/3.4/DBI_0.6-1.zip'
Content type 'application/zip' length 745244 bytes (727 KB)
downloaded 727 KB

tentando a URL 'http://cran.r-project.org/bin/windows/contrib/3.4/RMySQL_0.10.11.zip'
Content type 'application/zip' length 2296883 bytes (2.2 MB)
downloaded 2.2 MB

package ‘DBI’ successfully unpacked and MD5 sums checked
package ‘RMySQL’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
        C:\Users\alastori\AppData\Local\Temp\RtmpwLAGXJ\downloaded_packages

Step 3: Test your connection to MySQL

> library(DBI)
> ucscDb <- dbConnect(RMySQL::MySQL(), user="genome", host="genome-mysql.cse.ucsc.edu")
> result <- dbGetQuery(ucscDb,"show databases;"); dbDisconnect(ucscDb);
[1] TRUE
> result
              Database
1   information_schema
2              ailMel1
3              allMis1
4              anoCar1
5              anoCar2
...

Have fun!

    
02.06.2017 / 23:49