Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can't connect to local MySQL server through socket '/var/lib/mysql/mys

Status
Not open for further replies.

johnali3n

Programmer
Aug 11, 2004
1
GB
Hey all,

This error has been driving me mad for a few days now and I can't seem to solve it. I am not that new to mySQL or network architecture.

Here is the situation - I will try and explain it the best way I can.

First of all, the mySQL server is running inside a Smoothwall firewall. I am using a DMZ Pinhole to port 3306 from a webserver with public internet access, to the mySQL Mandrake 10.1 linux box inside the firewall on the internal LAN.

I am using mySQL v4.0.20

When I try to connect to the mySQL database, via HTTP only, from ANY other machine other than the mySQL server, I get the following error reported:-

Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /var/ on line 7
Connect Error: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

I am using a PHP script to access the mySQL database:-

<?php
$host="10.20.0.20";
$user="root";
$password="NOT TELLING YOU!!!";
$database="DOESN'T MATTER";
$connection=mysql_connect($hostName,$userName,$password) or die ('Couldnt select database');
$db=mysql_select_db($database,$connection);
?>

Obviously, I have substituted the $password and $database variables with junk.
The $host is the internal LAN address of the mySQL server that has access from the firewall using the DMZ pinhole.

The file '/var/lib/mysql/mysql.sock' does exist on the mySQL Mandrake 10.1 box but it is 0 bytes long - I am not sure if this is correct - Also I am not sure what permissions the directories are supposed to have. Currently, the owner and group is MYSQL.

I have uploaded some snapshots from the mySQL server, hopefully this will contain any information I have missed.


Here are the mySQL settings I have (although I can't find the my.cnf file ANYWHERE on the box - I have to use phpmyadmin to get the mySQL settings)

Variable Session value Global value
back log 50 50
basedir / /
binlog cache size 32768 32768
bulk insert buffer size 8388608 8388608
character set latin1 latin1
character sets latin1 big5 czech euc_kr gb2312 gbk latin1_de sjis tis620 ujis dec8 dos german1 hp8 koi8_ru latin2 swe7 usa7 cp1251 danish hebrew win1251 estonia hungarian koi8_ukr win1251ukr greek win1250 croat cp1257 latin5 latin1 big5 czech euc_kr gb2312 gbk latin1_de sjis tis620 ujis dec8 dos german1 hp8 koi8_ru latin2 swe7 usa7 cp1251 danish hebrew win1251 estonia hungarian koi8_ukr win1251ukr greek win1250 croat cp1257 latin5
concurrent insert ON ON
connect timeout 5 5
convert character set
datadir /var/lib/mysql/ /var/lib/mysql/
default week format 0 0
delay key write ON ON
delayed insert limit 100 100
delayed insert timeout 300 300
delayed queue size 1000 1000
flush OFF OFF
flush time 0 0
ft boolean syntax + -><()~*:""&| + -><()~*:""&|
ft min word len 4 4
ft max word len 254 254
ft max word len for sort 20 20
ft stopword file (built-in) (built-in)
have bdb NO NO
have crypt YES YES
have innodb YES YES
have isam YES YES
have raid NO NO
have symlink YES YES
have openssl NO NO
have query cache YES YES
init file
innodb additional mem pool size 1048576 1048576
innodb buffer pool size 8388608 8388608
innodb data file path ibdata1:10M:autoextend ibdata1:10M:autoextend
innodb data home dir
innodb file io threads 4 4
innodb force recovery 0 0
innodb thread concurrency 8 8
innodb flush log at trx commit 1 1
innodb fast shutdown ON ON
innodb flush method
innodb lock wait timeout 50 50
innodb log arch dir ./ ./
innodb log archive OFF OFF
innodb log buffer size 1048576 1048576
innodb log file size 5242880 5242880
innodb log files in group 2 2
innodb log group home dir ./ ./
innodb mirrored log groups 1 1
innodb max dirty pages pct 90 90
interactive timeout 28800 28800
join buffer size 131072 131072
key buffer size 8388600 8388600
language /usr/share/mysql/english/ /usr/share/mysql/english/
large files support ON ON
license GPL GPL
local infile ON ON
locked in memory OFF OFF
log OFF OFF
log update OFF OFF
log bin OFF OFF
log slave updates OFF OFF
log slow queries OFF OFF
log warnings ON ON
long query time 10 10
low priority updates OFF OFF
lower case file system OFF OFF
lower case table names 0 0
max allowed packet 1048576 1048576
max binlog cache size 4294967295 4294967295
max binlog size 1073741824 1073741824
max connections 100 100
max connect errors 10 10
max delayed threads 20 20
max insert delayed threads 20 20
max heap table size 16777216 16777216
max join size 4294967295 4294967295
max relay log size 0 0
max seeks for key 4294967295 4294967295
max sort length 1024 1024
max user connections 0 0
max tmp tables 32 32
max write lock count 4294967295 4294967295
myisam max extra sort file size 268435456 268435456
myisam max sort file size 2147483647 2147483647
myisam repair threads 1 1
myisam recover options OFF OFF
myisam sort buffer size 8388608 8388608
net buffer length 16384 16384
net read timeout 30 30
net retry count 10 10
net write timeout 60 60
new OFF OFF
open files limit 1024 1024
pid file /var/lib/mysql/DBNAS.pid /var/lib/mysql/DBNAS.pid
log error
port 3306 3306
protocol version 10 10
query alloc block size 8192 8192
query cache limit 1048576 1048576
query cache size 0 0
query cache type ON ON
query prealloc size 8192 8192
range alloc block size 2048 2048
read buffer size 131072 131072
read only OFF OFF
read rnd buffer size 262144 262144
rpl recovery rank 0 0
server id 0 0
slave net timeout 3600 3600
skip external locking ON ON
skip networking OFF OFF
skip show database OFF OFF
slow launch time 2 2
socket /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock
sort buffer size 2097144 2097144
sql mode 0 0
table cache 64 64
table type MYISAM MYISAM
thread cache size 0 0
thread stack 196608 196608
tx isolation REPEATABLE-READ REPEATABLE-READ
timezone BST BST
tmp table size 33554432 33554432
tmpdir /tmp/ /tmp/
transaction alloc block size 8192 8192
transaction prealloc size 4096 4096
version 4.0.20 4.0.20
version comment Source distribution Source distribution
version compile os mandrake-linux-gnu mandrake-linux-gnu
wait timeout 28800 28800



PLEASE HELP!!!!!!!!! :)
 
Some RPM's put the mysql.sock file
in /var/lib/mysql/mysql.sock instead
of /tmp/mysql.sock
Small hack is to symlink it:
"ln -s /var/lib/mysql/mysql.sock /tmp"

found this around the net
 
Code:
<?php
// Here you set $host
    $host="10.20.0.20";
    $user="root";
    $password="NOT TELLING YOU!!!";
             $database="DOESN'T MATTER";
// Here you use $hostName
    $connection=mysql_connect($hostName,$userName,$password) or die ('Couldnt select database');
    $db=mysql_select_db($database,$connection);
?>
Since $hostName is unset it's trying to make a local connection.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top