Thursday, June 20, 2013

mysql_connect(): Can't connect to local MySQL server

Description

Problem from a PHP application connecting to a local MySQL server database.

Sample Error

PHP Warning:  mysql_connect(): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (11)

Possible causes

  • Your local MySQL database is down or not responding via its local server socket IP address and port.
  • Verify the physical utilization of your physical server hosting MySQL and determine if you are dealing with high CPU and/or other resource utilization. CPU saturation can also cause connection failures from client such as Apache, PHP when trying to connect to the MySQL database server socket port.

 References and Case Studies