Re: [PHP] Re: PHP 5 MySql 4.1 issue - can't connect to mysql.sock

2004-12-20 Thread Barley
Bingo. Many thanks.


 Barley wrote:

  If I run the script from a shell prompt as root, it outputs Yes. If I
run
  as any other user, it outputs No. It also gives this error:
  Warning: mysqli_connect(): Can't connect to local MySQL server through
  socket '/var/lib/mysql/mysql.sock' (13)

 Check permissions on /var/lib/mysql. From the sockets manpage:

 NOTES
 In the Linux implementation, sockets which are visible in the filesystem
 honour the permissions of the directory they are in. Their owner, group
 and their permissions can be changed. Creation of a new socket will fail
 if the process does not have write and search (execute) permission on
 the directory the socket is created in. Connecting to the socket object
 requires read/write permission. This behavior differs from many
 BSD-derived systems which ignore permissions for Unix sockets. Portable
 programs should not rely on this feature for security.

 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] PHP 5 MySql 4.1 issue - can't connect to mysql.sock

2004-12-18 Thread Barley
I am familiar with MySql, Linux and database programming in general, but I
have not used PHP very much.

On my server, I had an application running just fine under PHP 4.1 and MySql
3.23. For various reasons, I needed to move to MySql 4.1. When I did so, the
PHP application was broken. I poked around and found that I needed to
upgrade to PHP 5 to get mysqli support. I did so with no problems. I built
PHP from source on a RedHat 7.3 box.

Here's the problem: I can only connect to MySql via a PHP script if I run
that script as root. Here is the example script I have been using:

?php
$DB = mysqli_connect(localhost,user,pass);
if (! $DB) {
echo No.;
} else {
echo Yes.;
}
?

If I run the script from a shell prompt as root, it outputs Yes. If I run
as any other user, it outputs No. It also gives this error:
Warning: mysqli_connect(): Can't connect to local MySQL server through
socket '/var/lib/mysql/mysql.sock' (13)

This means I can't run PHP scripts via apache.

I can log in to mysql via the command line with user/pass without any
problems.

Apache is connecting to PHP no problem, as I have a Hello world type PHP
script running and can access it via the web.

But no PHP script can connect to MySql unless it is run as root...

Can anyone point me in the right direction? I have a feeling this is
something very simple. Thanks!

Gregg