'Can't connect to local MySQL server' mesage.

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
tweet
Forum Newbie
Posts: 13
Joined: Wed May 28, 2003 1:18 am

'Can't connect to local MySQL server' mesage.

Post by tweet »

redhat9.0 used.
mysql4.0.15a.tar.gz installed............
mysql-server running.....
Warning: mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /data/guestbook/guestbook.php on line 7
Unable to select database

what's problem?
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

is the mysql server daemon running?

ps -axw | grep mysqld
tweet
Forum Newbie
Posts: 13
Joined: Wed May 28, 2003 1:18 am

..............

Post by tweet »

mysql server automatically start at boot-time
added /bin/sh -c 'cd /usr/local/mysql/bin/mysqld_safe --user=mysql &'
in /etc/init.d/rc.local file
[root@localhost root]# ps -axw | grep mysqld
725 ? S 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/usr/local/mysql/var --pid-file=/usr/local/mysql/var/localhost.localdomain.pid
759 ? S 0:00 [mysqld]
1177 pts/1 S 0:00 grep mysqld
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

Can you connect with the mysql cli utility?

mysql -u username -p databasename

What is the permissions of /tmp ?
tweet
Forum Newbie
Posts: 13
Joined: Wed May 28, 2003 1:18 am

.........

Post by tweet »

document root "/data' changed in httpd.conif...
run in /data directory when run php


when install php , dso module way installed.
$localhostname = "localhost"; // Point this to where the MySQL server is listenting.
$username = "root"; // MySQL username
$password = ""; // MySQL password
$database = "guestbook"; // The database you wish to use for hpMyGuestBook.php

can't connect mysql client.
[root@localhost guestbook]# mysql -u root guestbook
bash: mysql: command not found

tmp permission.
drwxrwxrwt 21 root root 2048 tmp

but, strange point, mysql.sock file haven't in /tmp.
mysql.sock file haven't on entire system.
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

the socket file is created by the client library, so tmp must be world writeable, which yours seem to be..

if you dont have the mysql cli client that may indicate that you do not have the mysql client libraries installed... perhaps some rpm package for that?

try find the mysql cli binary first, see if it is executable:
find / -name mysql -exec ls -l {} \;
Post Reply