database apps that ignore sockets? [was: Solution: mysqld fails to run, can't create/find mysql.sock]

Matthew Seaman m.seaman at infracaninophile.co.uk
Sun Jan 15 18:03:31 UTC 2012


On 15/01/2012 17:50, Paul Beard wrote:
> The app configurations are not this granular: hostname and port are
> configured but there is nothing that makes clear that IF you specify
> localhost, you WILL BE using a domain socket which MUST BE
> /tmp/mysql.sock and IF you move it or your distribution prefers some
> other location you MAY NOT use localhost as you are now using a TCP
> socket which shouldn't require a hostname but because of the way the
> app is written, it does.

You can specify an alternate socket location in your connection
parameters.  For the command line client, it is:

   mysql -S /var/run/mysql/sock

This doesn't help if you say 'mysql -h localhost' and get diverted to
use the default socket though -- in that case you can have a .my.cnf
file containing (inter-alia)

[client]
   socket = /var/run/mysql/sock

For the various language APIs, you generally need to specify a DSN
string -- usually this looks something like

   mysql:database=$database;host=$hostname;port=$port

but for a socket connection you could say instead:

   mysql:database=$database;mysql_socket=/var/run/mysql/sock

... assuming that whoever wrote the application you're using made it
sufficiently flexible as to be able to accept something like that.

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                  Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
JID: matthew at infracaninophile.co.uk               Kent, CT11 9PW

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 267 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20120115/f7dee1c8/signature.pgp


More information about the freebsd-questions mailing list