QuickAnswer
by

error handling Can't connect to local MySQL server through socket /tmp/mysql.sock

error handling Can't connect to local MySQL server through socket /tmp/mysql.sock

If you get an error like the following

Error: [Cake\Database\Exception\MissingConnectionException] Connection to Mysql could not be established: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /path/to/vendor/cakephp/cakephp/src/Database/Driver.php on line 121

Caused by: [PDOException] SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) in /path/to/vendor/cakephp/cakephp/src/Database/Driver.php on line 118

localhost to 127.0.0.1

In some cases, it is sufficient to create an empty file /tmp/mysql.sock, but in most cases, the following will solve the problem.

Rewrite localhost in the host settings to 127.0.0.1. Or add it.

CONTENTS
Web Browser