On 2 June 2010, Eugene Yunak <e.yu...@gmail.com> wrote: > On 2 June 2010 20:48, Liviu Daia <liviu.d...@imar.ro> wrote: > > 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 > > > > B B Please, stop perpetrating this nonsense. B This only works until you > > restart mysqld. B The reason is mysqld removes the socket when it starts > > before creating it anew. > > > > B B 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. B 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 > > > > I fail to see how this is nonsense or what stops one from creating > this hardlink in rc.local (which would be normally used to start mysql > anyway).
Like I said, it stops working when you restart mysqld. This doesn't necessarily happen at boot. If, for whatever reason, you restart mysqld manually, will you remember to re-create the link? > Your solution however works as well, of course. Regards, Liviu Daia -- Dr. Liviu Daia http://www.imar.ro/~daia