Hi All,
First, the problem I am having---
I have written a basic, basic PHP script to test database connection. It is included below. When I run the script, the get the following error message from the browser:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
However, my default mysql.sock location is /tmp/mysql.sock, as seen in the out put from mysqladmin:
Version: '4.0.14-log' socket: '/tmp/mysql.sock' port: 3306
The file mysql.sock exists in /tmp, but it has a file length of zero. (????)
When I modify the script to include the location of mysql.sock, the script works. Again, this script is listed below.
Any ideas?? Thanks Much!
Enviroment
O/S = RedHat Version9
PHP= 4.3.2
mySQL = 4.0.14
Test Script That Does NOT Work
<?
$connection = @mysql_connect("localhost:", "root", "") or die(mysql_error());
if ($connection) {
$msg = "success!";
}
?>
<HTML>
<HEAD>
<TITLE>MySQL Connection</TITLE>
</HEAD>
<BODY>
<? echo "$msg"; ?>
</BODY>
</HTML>
Test Script That DOES Work
Specifies Location of mysql.sock
<?
$connection = @mysql_connect("localhost:/tmp/mysql.sock", "root", "") or die(mysql_error());
if ($connection) {
$msg = "success!";
}
?>
<HTML>
<HEAD>
<TITLE>MySQL Connection</TITLE>
</HEAD>
<BODY>
<? echo "$msg"; ?>
</BODY>
</HTML>
Part of /etc/my.cnf File
The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
Here follows entries for some specific programs
The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
myisam_sort_buffer_size = 8M