Problem accessing MySQL from PHP

[email protected] (Max Space)
Newsgroups php.general
Message-ID <[email protected]>
Hi all, I am having problems accessing MySQL, any hints would be

appreciated:

Trying to access MySQl from the command line as root or 
mysql works fine. As "nobody" it gives me the following:

ERROR 2002: Can't connect to local MySQL server through socket
'/var/lib/mysql/mysql.sock' (111) 

Trying to access MySQL from a PHP script gives me a similar
message:

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

After trying a few things the following works from the command
line:

$ su nobody
$ mysql -h 127.0.0.1

MySQL comes up and I have access to all the databases. 

I changed from "localhost" to "127.0.0.1" in the PHP script and 
now do not get the warning but the connection still does not 
work.

Any help would be very welcome

/maxman



-------
Possibly useful information: the first line of /etc/hosts is:
127.0.0.1	localhost	localhost.localdomain 

-------
ls -l /var/lib/mysql gives in part the following:

-rw-------   1 mysql    mysql       15959 May 11 12:39
localhost.localdomain.err
-rw-rw----   1 mysql    mysql        8448 May 11 14:30
localhost.log
-rw-r--r--   1 mysql    mysql           4 May 11 12:39
localhost.pid
drwxr-xr-x   2 mysql    mysql        1024 May 11 12:03 mysql
srwxrwxrwx   1 mysql    mysql           0 May 11 12:39
mysql.sock

-------

mysqladmin  Ver 8.0 Distrib 3.22.32, for pc-linux-gnu on i686
TCX Datakonsult AB, by Monty

Server version		3.22.32-log
Protocol version	10
Connection		Localhost via UNIX socket
UNIX socket		/var/lib/mysql/mysql.sock
Uptime:			2 hours 7 min 9 sec

Threads: 6  Questions: 26  Slow queries: 0  Opens: 8  Flush
tables: 1  Open tables: 4
+----------------------------+------------------------------+
| Variable_name              | Value                        |
+----------------------------+------------------------------+
| back_log                   | 5                            |
| connect_timeout            | 5                            |
| basedir                    | /                            |
| datadir                    | /var/lib/mysql/              |
| delayed_insert_limit       | 100                          |
| delayed_insert_timeout     | 300                          |
| delayed_queue_size         | 1000                         |
| join_buffer                | 131072                       |
| flush_time                 | 0                            |
| key_buffer                 | 16773120                     |
| language                   | /usr/share/mysql/english/    |
| log                        | ON                           |
| log_update                 | OFF                          |
| long_query_time            | 10                           |
| low_priority_updates       | OFF                          |
| max_allowed_packet         | 1047552                      |
| max_connections            | 100                          |
| max_connect_errors         | 10                           |
| max_delayed_insert_threads | 20                           |
| max_join_size              | 4294967295                   |
| max_sort_length            | 1024                         |
| max_write_lock_count       | 4294967295                   |
| net_buffer_length          | 16384                        |
| pid_file                   | /var/lib/mysql/localhost.pid |
| port                       | 3306                         |
| protocol_version           | 10                           |
| record_buffer              | 131072                       |
| skip_locking               | ON                           |
| skip_networking            | OFF                          |
| socket                     | /var/lib/mysql/mysql.sock    |
| sort_buffer                | 2097144                      |
| table_cache                | 64                           |
| thread_stack               | 131072                       |
| tmp_table_size             | 1048576                      |
| tmpdir                     | /tmp/                        |
| version                    | 3.22.32-log                  |
| wait_timeout               | 28800                        |
+----------------------------+------------------------------+


__________________________________________________
Do You Yahoo!?
Send instant messages & get email alerts with Yahoo! Messenger.
http://im.yahoo.com/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.