[GRASS-user] MySQL mysql.sock GRASS connection problem

Mark Ruddy m.ruddy at rhul.ac.uk
Sun Sep 28 06:30:46 EDT 2008


Thanks for the information Glynn,

 From the documentation, not specifying a host shouldn't matter as  
mysql is on localhost and even if i specify host=localhost the UNIX  
socket will still be used. I have tried specifying the port but still  
nothing. I can't understand how I can change the default behaviour  
from the client library. I guess my current level of experience isn't  
great enough yet.

I have done a work-around by creating symbolic link from the true  
mysql.sock to /tmp/mysql.sock. db.connection is working. If you have  
more specific alternative suggestions I'd be happy to hear them.

My MySQL installation is from MAMP. I know a lot of fellow students  
who are using or are about to use MAMP/GRASS/R etc. Would it be a  
good idea to modify the GRASS-MySQL connection to avoid socket issues  
like this? This is a debate for another list though. I'll post  
elsewhere.

Many thanks for your response,

Mark



On 28 Sep 2008, at 01:29, Glynn Clements wrote:

>
> Mark Ruddy wrote:
>
>> I am having problems connecting to a local MySQL db from GRASS.
>>
>> using the following commands i get the error below...
>>
>>> db.connect driver=mysql database=dbname
>>> db.login user=user pass=password
>>> db.tables -p
>> DBMI-MySQL driver error:
>> Cannot connect to MySQL: Can't connect to local MySQL server through
>> socket '/tmp/mysql.sock' (2)
>>
>> A far as I was aware this is general error to do with some
>> installations of MySQL placing mysql.sock somewhere else other than /
>> tmp. I encountered this before when trying to connect another MySQL
>> client (R) and easily solved the problem by editing the /etc/my.cnf
>> file to contain the true [client]  location of mysql.sock. GRASS
>> seems to be ignoring the /etc/my.cnf file though and seems to be
>> still trying to locate mysql.sock in /tmp. All my other MySQL clients
>> don't have a socket problem. Does GRASS take its MySQL global configs
>> from some other location? Is something else wrong? Any help would be
>> greatly appreciated.
>>
>> I'm running GRASS 6.2.1 courtesy of OpenOSX on Mac OSX 10.4.11 with
>> MySQL 5.0.19.
>
> The MySQL driver never tries to force the use of a specific socket
> path.
>
> It connects using:
>
>     res = mysql_real_connect ( connection, connpar.host, user,  
> password,
> 	                       connpar.dbname, connpar.port, NULL, 0);
>
> [ http://trac.osgeo.org/grass/browser/grass/tags/ 
> release_20061212_grass_6_2_1/db/drivers/mysql/db.c ]
>
> If you specify just a database name to db.connect, connpar.host will
> be NULL, which will cause it to use a Unix-domain socket. The
> unix_socket parameter is always NULL, which causes the client library
> to use the default socket path.
>
> [ http://dev.mysql.com/doc/refman/5.0/en/mysql-real-connect.html ]
>
> -- 
> Glynn Clements <glynn at gclements.plus.com>



More information about the grass-user mailing list