Can't connect to local MySQL server through socket '/tmp/mysql.sock' (13)
I had done the native compilation of,
1. php-5.2.5
2. httpd-2.2.6
3. mysql 4.1.12
on power pc. The compilation went well!
Mysql works! and even i am able to connect to the database using mysql/mysqli php extension API (through command-line). If i try to connect through php page running through apache, i am getting the error "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13) Any idea why it's happening?
i had tried both mysql and mysqli php extensions, both returns the connection error when it's tried from php page. it works fine from php command.
sh-2.05b# php -r "mysql_connect('localhost','root','');"
sh-2.05b# php -r "mysqli_connect('localhost', 'root', '', 'emp');"
dump of mysql_test.php
=======================
<?php
$link = mysqli_connect("localhost", "root", "", "emp");
/* check connection */
if (!$link) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
printf("Host information: %s\n", mysqli_get_host_info($link));
/* close connection */
mysqli_close($link);
?>
page returns, Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)
mysqladmin version
====================
sh-2.05b# mysqladmin version
mysqladmin Ver 8.41 Distrib 4.1.12, for unknown-linux-gnu on powerpc
Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL license
Server version 4.1.12-log
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/lib/mysql/mysql.sock
Uptime: 18 sec
Dump of /etc/my.cnf
------------------
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock
# Here follows entries for some specific programs
[mysqld_safe]
port = 3306
socket = /var/lib/mysql/mysql.sock
# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-locking
key_buffer = 16M
max_allowed_packet = 1M
table_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin=mysql-bin
server-id = 1
[mysqldump]
quick
max_allowed_packet = 16M
[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates
[isamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[myisamchk]
key_buffer = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
php.ini
=======
[MySQL]
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_socket =/var/lib/mysql/mysql.sock
mysql.default_host =
mysql.default_password =
mysql.connect_timeout = 60
mysql.trace_mode = On
[MySQLi]
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =/var/lib/mysql/mysql.sock
mysqli.default_host =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = Off