if you host a cPanel/whm web-server you may at some point have reports that client sites are displaying a message similar to: “Can’t connect to local MySQL server through socket ‘/var/tmp/mysql.sock’”
Here are a few quick steps to resolve the error if the location of your mysql.sock file is incorrect. This can occur after an automatic upgrade or similar scenario.
Check cPanel’s reference to mysql.sock file:
- Log onto WHM, go to the PHP editor -> Advanced mode and search for “mysql.default_socket”.
- Check the value in “mysql.default_socket” matches a cPanel writable and secure location.
- SSH to your server and use “locate mysql.sock” to see where the sock file is. Ensure your “mysql.default_socket” field matches the location.
Note: Two likely locations for this are:
- You may need to restart mySQL afterwards.