Try mysqli_connect("127.0.0.1", "user", "pass");
Then MySQLI will try to use TCP/IP as opposed to a local socket.
Jed
Barley wrote:
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
-- _ (_)___ Jed Smith, Code Monkey | / __| jed@xxxxxx | jed@xxxxxxx | \__ \ +1 541 606-4145 _/ |___/ Signed mail preferred (PGP 0x703F9124) |__/ http://personal.jed.bz/keys/jedsmith.asc
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php