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
Category:PHP
Pub.date:2020-07-17
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
JavaScript
Unreal Engine
CakePHP4
CakePHP4
Flutter
Flutter
Other
JavaScript
JavaScript
CakePHP4
Web Server
Photoshop
Unreal Engine
CakePHP4
Web Browser
Web Server
iOS
Android
Web Browser
CakePHP4
Plesk
Illustrator
Plesk
Web Server
Web Server
CakePHP3
Web Browser
CakePHP3
JavaScript
JavaScript
CakePHP3
CakePHP3