On 2 June 2010, Eugene Yunak <e.yu...@gmail.com> wrote:
> On 1 June 2010 16:30, What you get is Not what you see
> <wygin...@gmail.com> wrote:
> > Freshly installed on openbsd 4.6 mysql,php and php5-mysql packages.
> > Done the configs. Now php and mysql works. But I couldnt make it
> > connect to mysql from within php with such a command
> > mysql_connect("localhost","user","pass")
> > It used to give "Cant connect to mysql through socket error" till I
> > change the command to
> > mysql_connect(127.0.0.1,"user","pass")
> > I want to learn why?
> >
> 
> As you've been already told, this is because default apache is
> chrooted and thus cannot access mysql socket.
> To correct it, just do
> 
> # mkdir -p /var/www/var/run/mysql
> # ln -f /var/run/mysql/mysql.sock /var/www/var/run/mysql/mysql.sock

    Please, stop perpetrating this nonsense.  This only works until you
restart mysqld.  The reason is mysqld removes the socket when it starts
before creating it anew.

    If you really must use a socket instead of TCP then move the socket
to jail and give programs different views to it from inside and outside
the jail, using my.cnf.  Not tested:

- in /etc/my.cnf:

socket = /var/www/var/run/mysql/mysql.sock

- in /var/www/etc/my.cnf:

socket = /var/run/mysql/mysql.sock

    Regards,

    Liviu Daia

-- 
Dr. Liviu Daia                                  http://www.imar.ro/~daia

Reply via email to