L. V. Lammert | 1 Jun 2010 15:45

Re: Mysql connection from within php

On Tue, 1 Jun 2010, What you get is Not what you see 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?
>
Because the socket is in /var, .. and default apache chroot's to /var/www.
I believe there are tricks to make it work, but it's simpler to
just connect  <at> 127.0.0.1.

	Lee

Vadim Agarkov | 1 Jun 2010 18:41
Picon

Re: Mysql connection from within php

01.06.2010 16:45, L. V. Lammert P?P8QP5Q:
> On Tue, 1 Jun 2010, What you get is Not what you see 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?
>>
>>
> Because the socket is in /var, .. and default apache chroot's to /var/www.
> I believe there are tricks to make it work, but it's simpler to
> just connect  <at> 127.0.0.1.
>
> 	Lee
>
>

try to create hosts file for chrooted apache.

$ cat /var/www/etc/hosts
127.0.0.1 localhost
$

--
thanks.
(Continue reading)


Gmane