[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 00:09:01 CEST 2009



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




More information about the R-sig-DB mailing list