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