Quantcast

connecting to mysql socket

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

connecting to mysql socket

Robert Moskowitz
I solved my mysql access problem with dovecot; turned out it was trying
a tcp connection and mysql is not listening on tcp.  Fixed that to use
mysql.sock.

So this got me digging into how postfix was successfully accessing
mysql.  I see in my various .cf files that access mysql that I have:

host= localhost

And reading the docs (what read the docs?), this tells postfix to
connect to mysql via the default UNIX domain socket.  How does it know
what the file handle is?  It seems to be working...

Should I force it with:

host = unix:/var/lib/mysql/mysql.sock

instead?  Which is the sock that I am successfully using with dovecot
and amavis.

Plus it better documents the behavior instead of relying on reading the
docs...

thanks


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: connecting to mysql socket

Wietse Venema
Robert Moskowitz:

> I solved my mysql access problem with dovecot; turned out it was trying
> a tcp connection and mysql is not listening on tcp.  Fixed that to use
> mysql.sock.
>
> So this got me digging into how postfix was successfully accessing
> mysql.  I see in my various .cf files that access mysql that I have:
>
> host= localhost
>
> And reading the docs (what read the docs?), this tells postfix to
> connect to mysql via the default UNIX domain socket.  How does it know
> what the file handle is?  It seems to be working...

It doesn't. Postfix makes all MySQL requests through the mysql
library.  For best results, use the library that matches the server
(so that they use the same default socket, among other things).

        Wietse
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: connecting to mysql socket

Robert Moskowitz


On 04/07/2017 01:19 PM, Wietse Venema wrote:

> Robert Moskowitz:
>> I solved my mysql access problem with dovecot; turned out it was trying
>> a tcp connection and mysql is not listening on tcp.  Fixed that to use
>> mysql.sock.
>>
>> So this got me digging into how postfix was successfully accessing
>> mysql.  I see in my various .cf files that access mysql that I have:
>>
>> host= localhost
>>
>> And reading the docs (what read the docs?), this tells postfix to
>> connect to mysql via the default UNIX domain socket.  How does it know
>> what the file handle is?  It seems to be working...
> It doesn't. Postfix makes all MySQL requests through the mysql
> library.  For best results, use the library that matches the server
> (so that they use the same default socket, among other things).

I read this response to just leave it as host = localhost, as everything
is local on the one server.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: connecting to mysql socket

John Fawcett
On 04/07/2017 07:33 PM, Robert Moskowitz wrote:

>
>
> On 04/07/2017 01:19 PM, Wietse Venema wrote:
>> Robert Moskowitz:
>>> I solved my mysql access problem with dovecot; turned out it was trying
>>> a tcp connection and mysql is not listening on tcp.  Fixed that to use
>>> mysql.sock.
>>>
>>> So this got me digging into how postfix was successfully accessing
>>> mysql.  I see in my various .cf files that access mysql that I have:
>>>
>>> host= localhost
>>>
>>> And reading the docs (what read the docs?), this tells postfix to
>>> connect to mysql via the default UNIX domain socket.  How does it know
>>> what the file handle is?  It seems to be working...
>> It doesn't. Postfix makes all MySQL requests through the mysql
>> library.  For best results, use the library that matches the server
>> (so that they use the same default socket, among other things).
>
> I read this response to just leave it as host = localhost, as
> everything is local on the one server.
>
>
should be

hosts = localhost

John

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: connecting to mysql socket

Robert Moskowitz


On 04/07/2017 01:38 PM, John Fawcett wrote:

> On 04/07/2017 07:33 PM, Robert Moskowitz wrote:
>>
>> On 04/07/2017 01:19 PM, Wietse Venema wrote:
>>> Robert Moskowitz:
>>>> I solved my mysql access problem with dovecot; turned out it was trying
>>>> a tcp connection and mysql is not listening on tcp.  Fixed that to use
>>>> mysql.sock.
>>>>
>>>> So this got me digging into how postfix was successfully accessing
>>>> mysql.  I see in my various .cf files that access mysql that I have:
>>>>
>>>> host= localhost
>>>>
>>>> And reading the docs (what read the docs?), this tells postfix to
>>>> connect to mysql via the default UNIX domain socket.  How does it know
>>>> what the file handle is?  It seems to be working...
>>> It doesn't. Postfix makes all MySQL requests through the mysql
>>> library.  For best results, use the library that matches the server
>>> (so that they use the same default socket, among other things).
>> I read this response to just leave it as host = localhost, as
>> everything is local on the one server.
>>
>>
> should be
>
> hosts = localhost

It is.  I should have cut and paste instead of typing from memory...

thanks


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: connecting to mysql socket

Phil Stracchino
In reply to this post by Robert Moskowitz
On 04/07/17 11:51, Robert Moskowitz wrote:

> I solved my mysql access problem with dovecot; turned out it was trying
> a tcp connection and mysql is not listening on tcp.  Fixed that to use
> mysql.sock.
>
> So this got me digging into how postfix was successfully accessing
> mysql.  I see in my various .cf files that access mysql that I have:
>
> host= localhost
>
> And reading the docs (what read the docs?), this tells postfix to
> connect to mysql via the default UNIX domain socket.  How does it know
> what the file handle is?  It seems to be working...


You need to understand certain nuances of MySQL's 'host' directive.
Most of us are used to 'localhost' and '127.0.0.1' being equivalent.  In
MySQL, they aren't.

In MySQL, using host = 127.0.0.1 directs clients to connect to mysqld
via port 3306 on the loopback network interface.  However, host =
localhost, as you found, instructs the client to use the Unix domain
socket instead.

If any client app that uses libmysqlclient is having trouble *finding*
that socket, the first thing to try is adding the directive 'socket =
<actual socket location>' in the [client] section of /etc/my.cnf.

So in your case, try:

[client]
host = localhost
socket = /var/lib/mysql/mysql.sock


--
   Phil Stracchino
   Babylon Communications
   [hidden email]
   [hidden email]
   Landline: 603.293.8485
Loading...