Skip to content

Instantly share code, notes, and snippets.

@jlengstorf
Last active December 15, 2015 01:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlengstorf/5184301 to your computer and use it in GitHub Desktop.
Save jlengstorf/5184301 to your computer and use it in GitHub Desktop.

"No such file or directory" Error for mysql.sock

When trying to connect to a MySQL database using localhost, some server configurations will throw the following error:

No such file or directory (trying to connect via unix:///var/mysql/mysql.sock)

To correct this error, all that's required is to update the location of mysql.sock in php.ini.

In php.ini, search for the following line and update it with the location of mysql.sock:

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/mysql.default-socket
mysql.default_socket = /var/mysql/mysql.sock
# Figure out where the PHP configuration file lives
php --ini
# Determine where mysql.sock is located
msyqladmin version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment