Error connecting to DB.

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
xLechugasx
Forum Newbie
Posts: 14
Joined: Wed Aug 28, 2002 9:56 am

Error connecting to DB.

Post by xLechugasx »

Hi to all!!
My name is Nicolas and I am a new user of PHP and MySQL.
I am having the following error while trying to connect to a mysql database:

Can't connect to local MySQL server through socket '/tmp/mysql.sock'

I wrote the name and password ok, and in the host argument for the mysql_connect function I used localhost.

What can be wrong?
Thanks a lot,
Nicolas
kcomer
Forum Contributor
Posts: 108
Joined: Tue Aug 27, 2002 8:50 am

mysql running?

Post by kcomer »

is mysql running?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

mysql uses two ways to connect to a server
1) TCP as all know
2) sockets that are connected more like pipes

(2) is your problem

did you change mysql.default_socket in php.ini?
xLechugasx
Forum Newbie
Posts: 14
Joined: Wed Aug 28, 2002 9:56 am

Post by xLechugasx »

This is what is shown with phpinfo().
MySQL is running.

mysql
MySQL Support enabled
Active Persistent Links 0
Active Links 0
Client API version 3.23.49a
MYSQL_MODULE_TYPE external
MYSQL_SOCKET /tmp/mysql.sock
MYSQL_INCLUDE -I/usr/local/mysql/include
MYSQL_LIBS -L/usr/local/mysql/lib -lmysqlclient

what can I do??
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I'm not quite sure about this, but if you take a look in your mysqld-configuration (default is: my.cnf) you will find a parameter
[mysqld]
...
socket = /var/run/mysqld/mysqld.sock
whatever "socket" is set to, set it in the php.ini, too
Post Reply