On 21/07/05, chaton <[EMAIL PROTECTED]> wrote: > On Thu, 21 Jul 2005 10:35:38 +0300 > "Tomas" <[EMAIL PROTECTED]> wrote: > > > Hallo everyone, > > > > I've setup a web server with OpenBSD 3.7, default install Apache, PHP 5.0.3 > > and MySQL 4.0.23. When I connect from other hosts to mysql, everything works > > fine, and then I try to connect to mysql local console, it works too. I know > > that apache is chrooted so my rc.local looks like this: > > <--snip--> > > if [ X"${mysql}" == X"YES" -a -x /usr/local/bin/mysqld_safe ]; > > then > > echo -n ' mysqld'; > > /usr/local/bin/mysqld_safe --user=_mysql --bind-address=10.30.1.222 > > --log=/var/mysql/errorlog >/dev/null 2>&1 & > > for i in 1 2 3 4 5 6; > > do if [ -S /var/run/mysql/mysql.sock ]; > > then > > break > > else > > sleep 1 > > echo -n '.' > > fi done > > sleep 5 > > ln -sf /var/run/mysql/mysql.sock /var/www/var/run/mysql/mysql.sock > > fi > > </--snip--> > > Like you see I'm using soft link, it's because my /var and /var/www are on > > different mount points, so hard links can't be made. To test if socket is > > working I've issued this command: > > mysqladmin --socket=/var/www/var/run/mysql/mysql.sock version -u 'user' -p > > And it works perfectly, but when I try to use a test web page with code: > > <--snip--> > > <? > > $link = mysql_connect('localhost', 'user', 'password'); > > if (!$link) { > > die('Could not connect: ' . mysql_error()); > > } > > echo 'Connected successfully'; > > mysql_close($link); > > ?> > > </--snip--> > > I get an error: > > <--snip--> > > [error] PHP Warning: mysql_connect() [<a > > href='function.mysql-connect'>function.mysql-connect</a>]: Can't connect to > > local MySQL server through socket '/var/www/var/run/mysql/mysql.sock' (2) > > </--snip--> > > I've been playing around with this configuration for about too days and it > > seems I've tried everything, but I can't get it working, please help me, > > what I'm missing here... > > > > > > a soft link can't be created within a chroot()-ed area to "point" to a file > that is outside the chroot()-ed area (you might want to read about soft > links and how they actually work). > > what you need to do is have mysql create its socket within the chroot()-ed > area: > > mysqld_safe --socket=/var/www/var/run/mysql/mysql.sock > >
What worked for me was to create the dir /var/www/var/run/mysql and then ln -s /var/www/var/run/mysql /var/run/mysql ;)