Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Post by sean.mole » Tue, 17 Jul 2007 21:33:11


Hello All


I'm new to Linux and am trying to learn to develop PHP and MySQL web
applications but am stuck.


I'm running Suse 10.0 and have installed Apache, PHP and MySQL from
the DVD.


Apache, and PHP are working and <?php phpinfo(); ?> produces the
expected output.


MySQL is also working and I've used knoda to create a sample
database.


I'm using this php to try to connect to MySQL


$mysqluser = 'root';
$mysqlpasswd = 'mypassword123';
$mysqlhost = 'localhost';
$connID = mysql_connect($mysqlhost, $mysqluser, $mysqlpasswd);


However, when I try it I get:


Can't connect to local MySQL server through socket '/var/lib/mysql/
mysql.sock' (13) .


I've been searching the posts and understand that 13 means it is a
permissions problem. However all the reported causes I can find seem
OK on my machine.


1) MySQL is running
I've checked with mysqladmin ping and get the following


linux:~ # mysqladmin -p ping
Enter password:
mysqld is alive
linux:~ #


2) SELinux is disabled


I used usr/sbin/setenforce Permissive and now /usr/sbin/getenforce
says 'Disabled'


linux:~ #


3) mysql.sock is where I'd expect it to be with the expected mysql
owner, mysql group and expected permissions. I tested this like so.


linux:~ # ls -l /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 Jul 15 13:54 /var/lib/mysql/mysql.sock
linux:~ #


4) /var/lib/mysql/ has the expected mysql owner, mysql group and
expected permissions. I tested this like so.


5) /var/lib/mysql/ has the expected mysql owner, mysql group and
expected permissions. I tested this like so.


linux:~ # ls -l /var/lib/


......(omitting lines here)


drwxrwxrwx 7 mysql mysql 520 Jul 15 13:54 mysql


......(omitting lines here)


linux:~ #


6) I included myself in the mysql group.


Clearly, I am missing something but I don't know what.


My guess is it is something silly and simple, but it beats me. Any
help anyone can give would be greatly appreciated.
 
 
 

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Post by lark » Wed, 18 Jul 2007 00:48:56

== Quote from sean.moley ( XXXX@XXXXX.COM )'s article

make sure the user that runs the webserver can also read the socket file. i
believe that's the one that tries to read the socket file.
POST BY: lark with PHP News Reader

 
 
 

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Post by sean.mole » Wed, 18 Jul 2007 05:44:50


Thanks for the reply

Correct me if I'm wrong, but doesn't this indicate that all users have
full access to the socket


linux:~ # ls -l /var/lib/mysql/mysql.sock
srwxrwxrwx 1 mysql mysql 0 Jul 15 13:54 /var/lib/mysql/mysql.sock
linux:~ #

I assumed this covers whatever user runs the webserver?
 
 
 

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Post by lark » Wed, 18 Jul 2007 23:41:45

== Quote from sean.moley ( XXXX@XXXXX.COM )'s article
socket file. i
have

yes, it does! now check my.cnf to see if there is a line in there
for mysql.sock and/or its location. a lot of times, the socket file
ends up in /tmp/mysql.sock

POST BY: lark with PHP News Reader
 
 
 

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Post by sean.mole » Sat, 21 Jul 2007 04:37:36

Thanks for the reply and sorry for the delay in responding further.

The refs to mysql.sock in my.cnf look OK also

here they are.


# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /var/lib/mysql/mysql.sock


# The MySQL server
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
 
 
 

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Post by lark » Sat, 21 Jul 2007 23:07:49


one more thing to ask: have you installed php mysql extensions? when you
do a phpinfo(); it should list it.
 
 
 

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Post by sean.mole » Sun, 22 Jul 2007 17:49:03

n 20 Jul, 15:07, lark < XXXX@XXXXX.COM > wrote:


Thanks lark

A php page with <?php phpinfo(); ?> produces a web page with this
lot.


PHP LogoPHP Version 4.4.0


System Linux linux 2.6.13-15.16-default #1 Fri Jun 8 15:35:39 UTC
2007 i686
Build Date Jun 16 2007 00:00:45
Configure Command './configure' '--prefix=/usr' '--datadir=/usr/
share/php' '--mandir=/usr/share/man' '--bindir=/usr/bin' '--libdir=/
usr/share' '--includedir=/usr/include' '--sysconfdir=/etc' '--with-
_lib=lib' '--with-config-file-path=/etc' '--with-exec-dir=/usr/lib/php/
bin' '--disable-debug' '--enable-inline-optimization' '--enable-memory-
limit' '--enable-magic-quotes' '--enable-safe-mode' '--enable-
sigchild' '--disable-ctype' '--disable-session' '--without-mysql' '--
disable-cli' '--without-pear' '--with-openssl' '--with-apxs2=/usr/sbin/
apxs2-prefork' 'i586-suse-linux'
Server API Apache 2.0 Handler
Virtual Directory Support disabled
Configuration File (php.ini) Path /etc/php.ini
PHP API 20020918
PHP Extension 20020429
Zend Extension 20050606
Debug Build no
Zend Memory Manager enabled
Thread Safety disabled
Registered PHP Streams php, http, ftp, https, ftps, compress.zlib,
compress.bzip2


Zend logo This program makes use of the Zend Scripting Language
Engine:
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies


PHP Credits
Configuration
PHP Core
Directive
Local Value
Master Value
allow_call_time_pass_reference On On
allow_url_fopen On On
always_populate_raw_post_data Off Off
arg_separator.input & &
arg_separator.output & &
asp_tags Off Off
auto_append_file no value no value
auto_prepend_file no value no value
browscap no value no value
default_charset no value no value
default_mimetype text/html text/html
define_syslog_variables Off Off
disable_classes no value no value
disable_functions no value no value
display_errors On On
display_startup_errors Off Off
doc_root no value no value
docref_ext no value no value
docref_root no value no value
enable_dl On On
error_append_string no value no value
error_log no value no value
error_prepend_string no value no value
error_reporting 2039 2039
expose_php On On
extension_dir /usr/lib/php/extensions /usr/lib/php/extensions
file_uploads On On
gpc_order GPC GPC
highlight.bg #FFFFFF #FFFFFF
highlight.comment #FF8000 #FF8000
highlight.default #0000BB #0000BB
highlight.html #000000 #000000
highlight.keyword #007700 #007700
highlight.string #DD0000 #DD0000
html_errors On On
ignore_repeated_errors Off Off
ignore_repeated_source Off Off
ignore_user_abort Off Off
implicit_flush Off Off
include_path /usr/share/php /usr/share/php
log_errors Off Off
log_errors_max_len 1024 1024
magic_quotes_gpc On On
magic_quotes_runtime Off Off
magic_quotes_sybase Off Off
max_execution_time 30 30
max_input_nesting_level 64 64
max_input_time 60 60
memory_limit 8M 8M
open_basedir no value no value
output_buffering no value no value
output_handler no value no value
post_max_size 16M 16M
precision 12 12
register_argc_argv On On
register_globals Off Off
report_memleaks On On
safe_mode Off Off
safe_mode_exec_dir no value no value
safe_mode_gid Of
 
 
 

Can't connect '/var/lib/mysql/mysql.sock' (13) - but not the usual suspects

Post by sean.mole » Tue, 24 Jul 2007 06:35:03


Hi Lark

I'm stumped on this one and so I installed Fedora 7 and followed these
instructions.


http://www.yqcomputer.com/

It worked first time, so I'm working on Fedora for now and will come
back to Suse when I understand stuff better.


Thanks for your time