473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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

Hi

Environment: some version of Slackware, Apache 2.2.x, PHP 5.1.5, MySQL
5.0.24.

The issue: I'm using Zend Framework Zend_Db component (which uses PDO).
We have 2 mysql socket related settings in php.ini:

mysql.default_socket = /var/run/mysql/mysql.sock
mysqli.default_socket = /var/run/mysql/mysql.sock

On MySQL command prompt, query "SHOW VARIABLES LIKE '%socket%';"
returns the variable "socket" with correct (desired) value
"/var/run/mysql/mysql.sock".

But still, the output of phpinfo() contains the following lines in
mysql and mysqli sections, respectively:

MYSQL_SOCKET /tmp/mysql.sock
MYSQLI_SOCKET /tmp/mysql.sock

What's worse though is that PDO seems to be using the wrong
"/tmp/mysql.sock" socket and every once in a while the sites
mysteriously stop working and throw the following exception:

SQLSTATE[HY000] [2002] Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2)

I need a solution how to force PHP/MySQL/PDO (whatever causes this) to
use the specified socket (and stop throwing exceptions). I know that
there is a "unix_socket" option I can use in PDO connection string, but
since I don't directly use PDO but use Zend_Db instead, this is not
possible. I just need PDO to KNOW. (I don't know if the wrong
MYSQL_SOCKET and MYSQLI_SOCKET lines from phpinfo() affect this in any
way...?)

Thank you very much.

Michal

Aug 29 '06 #1
2 18732
Michal Stankoviansky wrote:

We have 2 mysql socket related settings in php.ini:

mysql.default_socket = /var/run/mysql/mysql.sock
mysqli.default_socket = /var/run/mysql/mysql.sock
<snip>
>
But still, the output of phpinfo() contains the following lines in
mysql and mysqli sections, respectively:

MYSQL_SOCKET /tmp/mysql.sock
MYSQLI_SOCKET /tmp/mysql.sock
Have you checked /etc/my.cnf? The environment vars?

HTH

C.

Aug 30 '06 #2
Colin McKinnon wrote:
Have you checked /etc/my.cnf? The environment vars?

I have checked MySQL environment variables and they held the correct
value ("/var/run/mysql/mysql.sock").

:-/

Michal

Sep 4 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Neo | last post by:
It's really strange. I downloaded the latest 4.0.16 RPM from mysql.com and installed it to my Fedora system, and did *not* do anything else (Actually I am completely new to mysql). I wrote a...
0
by: Bill Hernandez | last post by:
Hi, I've been writing software on the mac since 1987, but am brand new at unix/php/mysql, and that's where I'm headed so I'm reading everything I can get my hands on, but like anything else...
0
by: Ian | last post by:
Dear All, I just downloaded & installed MYSQL. It seemed to work and I can start it and enter my password and change a directory but that is about all. I have been ready and playing "hit & miss"...
3
by: Pugi! | last post by:
On a freshly installed Fedora C3 (incl. webserver apache php mysql) i get the following problem when connecting to mysql through a browser (phpMyAdmin): : #2002 Can't connect to local MySQL...
1
by: jiing | last post by:
Now let me describe what I have done and my purpose: Originally, I want to user ports to install phpBB But I found that phpBB doesn't support mysql 5.x (but the ports installed mySQL 5.0.0...
2
by: xiuchuanli | last post by:
I install Fedora 4 with web server, after that I installed mysql 5.0.15. Now I can connect to mysql from command line and mysql-administrator and mysql-query-browser. But when I try to test to...
1
by: linux | last post by:
Sorry if this is a really dumb question. I am trying to connect to our remote MySQL server (which is running just fine). I have a perl script which worked just fine on my other Fedora 4 box (all...
5
by: scorpionbilli | last post by:
Hi, The local mysql server is running on my Macbook. I can access it through the console client: $ mysql -u root Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL...
1
by: sasimca007 | last post by:
Hi friends, I installed mysql in ubuntu but, i don't know how to connect to that mysql. Actually we connect to postgresql by psql command, but when i tried to connect mysql with...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.