Skip to content
Back to formatted view

Raw Message

Message-ID: <69ACEDBD-C944-4E8C-ABDE-1685A00D71D3@louspringer.com>
Date: 2006-06-08T05:27:47Z
From: Louis Springer
Subject: R, RMySQL and OSX
In-Reply-To: <8A0CADA7-D38B-4352-AB3D-8FEC1E75B986@louspringer.com>

I've got at least a partial resolution and workaround to my issue.

The default unix.socket parameter on the dbConnect call is "/opt/ 
local/var/run/mysql5/mysqld.sock" if unix.sock is not specified. I'm  
not sure where this unix.socket is coming from, but it doesn't work  
for me.

The correct unix.sock parameter for my case is  "/tmp/mysql.sock".

This works:

con <- dbConnect(dbDriver("MySQL"), username="myuser",  
host="localhost", dbname="mydb", password="secret", unix.sock="/tmp/ 
mysql.sock")

This does not:

con <- dbConnect(dbDriver("MySQL"), username="myuser",  
host="localhost", dbname="mydb", password="secret")

I also have a patch to RS-MySQL.c to display the error message  
returned by MySQL on a connect error. What should I do with this? Who  
is the current maintainer for this code?

The bit around the "my_sql_real_connect" should read something like:

   if(!mysql_real_connect(my_connection, host, user, passwd, dbname,
		       port, unix_socket, client_flags)){
     char buf[2048];
     sprintf(buf, "could not connect %s@%s on dbname \"%s\"\nError:%s 
\n",
	    user, host, dbname, mysql_error(my_connection));
     RS_DBI_errorMessage(buf, RS_DBI_ERROR);
   }

The current version clobbers "my_connection" on a failed connection  
rendering any call to "mysql_error(my_connection)" useless. My hacked  
RS-MySQL.c returns:

Error in mysqlNewConnection(drv, ...) : RS-DBI driver: (could not  
connect myuser at localhost on dbname "mydb"
Error:Can't connect to local MySQL server through socket '/opt/local/ 
var/run/mysql5/mysqld.sock' (2)

for the error I was having, returning an informative mysql error  
message on the failed connection.


Lou

On Jun 7, 2006, at 9:58 PM, Louis Springer wrote:

> In reference to a meesage from "jhorn at bu.edu", installation and
> build problems on OSX Tiger for R and RMySQL, "RMySQL Error Messages,
> crashing R" (https://stat.ethz.ch/pipermail/r-sig-mac/2006-February/
> 002686.html), was Jason ever able to resolve the issues? I'm not
> getting any of the compile issues referred to, but am unable to
> connect, getting:
>
> RS-DBI driver: (could not connect xxx at localhost on dbname "dbname"
>
> My R version is R for Mac OS X Aqua GUI, 1.16 (3198), R 2.3.1  
> Framework
> RMySQL version RMySQL_0.5-7
> MySQL version mysql  Ver 14.12 Distrib 5.0.13-rc, for apple-
> darwin8.2.0 (powerpc) using readline 5.0
>
> Thanks,
> Lou
>
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
>


	[[alternative HTML version deleted]]