[R-sig-DB] RMySQL dbConnect( default.file="mysql.config" ) fails

Charles C. Berry cberry @end|ng |rom t@jo@uc@d@edu
Tue Sep 22 05:54:16 CEST 2009



It seems that the config file needs to specify the location of the socket 
else an incorrect location is given. Also the config file needs to be 
named according to its full path designation.

Perhaps, these requirements are bugs in dbConnect().

===

Putting

socket = /private/var/mysql/mysql.sock

in the [client] section works with

con3 <- dbConnect(m,  default.file="/<full-path>/mysql.config")

(note that the full path given in the line above is required)

Chuck

On Mon, 21 Sep 2009, Charles C. Berry wrote:

>
>
> I can connect to a database using
>
> 	dbConnect(m, dbname="intSites",user="3y996DKX7i",password="pass")
>
> but when I try using
>
> 	dbConnect(m, default.file="mysql.config")
>
> and similar calls I get an error: RS-DBI driver: (Failed to connect to 
> database ...
>
> Details follow. Please forgive a few line wraps. Help appreciated.
>
> Chuck
>
> ---
>>  # here is 'mysql.config' in getwd()
>>  readLines("mysql.config")
>  [1] "# config for intsite queries" ""
>  [3] "[client]"                     "user = 3y996DKX7i"
>  [5] "password = pass "             "host = localhost"
>  [7] ""                             "[rs-dbi]"
>  [9] "database = intSites"          ""
>> 
>
>>  library( RMySQL )
> Loading required package: DBI
>>  m <- MySQL()
>>  summary(m)
> <MySQLDriver:(82181)>
>   Driver name:  MySQL
>   Max  connections: 16
>   Conn. processed: 0
>   Default records per fetch: 500
>   Open connections: 0
>>
>>  # connecting with dbname,user,password WORKS OK
>>  con <- dbConnect(m, dbname="intSites",user="3y996DKX7i",password="pass")
>>  summary(con)
> <MySQLConnection:(82181,0)>
>   User: 3y996DKX7i
>   Host: localhost
>   Dbname: intSites
>   Connection type: Localhost via UNIX socket
>   No resultSet available
>>
>>  # but using default.file seems to fail
>>  con2 <- dbConnect(m, default.file="mysql.config")
> Error in mysqlNewConnection(drv, ...) :
>  RS-DBI driver: (Failed to connect to database: Error: Can't connect to 
> local MySQL server through socket '/tm\
> p/mysql.sock' (2)
> )
>>  # try again, but specify group
>>  con2 <- dbConnect(m, group="client", default.file="mysql.config")
> Error in mysqlNewConnection(drv, ...) :
>  RS-DBI driver: (Failed to connect to database: Error: Can't connect to 
> local MySQL server through socket '/tm\
> p/mysql.sock' (2)
> )
>>  con2 <- dbConnect(m, group="rs-dbi", default.file="mysql.config")
> Error in mysqlNewConnection(drv, ...) :
>  RS-DBI driver: (Failed to connect to database: Error: Can't connect to 
> local MySQL server through socket '/tm\
> p/mysql.sock' (2)
> )
>>  sessionInfo()
> R version 2.9.0 (2009-04-17)
> i386-apple-darwin8.11.1
>
> locale:
> C
>
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> other attached packages:
> [1] RMySQL_0.7-4 DBI_0.2-4
>> 
>
>
> Charles C. Berry                            (858) 534-2098
>                                            Dept of Family/Preventive 
> Medicine
> E mailto:cberry using tajo.ucsd.edu	            UC San Diego
> http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901
>
> _______________________________________________
> R-sig-DB mailing list -- R Special Interest Group
> R-sig-DB using stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-db
>

Charles C. Berry                            (858) 534-2098
                                             Dept of Family/Preventive Medicine
E mailto:cberry using tajo.ucsd.edu	            UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/  La Jolla, San Diego 92093-0901




More information about the R-sig-DB mailing list