laravel SQLSTATE[HY000] [2002] No such file or directory code example

Example 1: Illuminate\Database\QueryExceptionSQLSTATE[HY000] [2002] No such file or directory

Add mysql.sock path in database.php file

Example 2: drush SQLSTATE[HY000] [2002] No such file or directory

$databases['default']['default'] = array (
  'database' => 'drupal',
  'username' => 'root',
  'password' => 'root',
  'prefix' => '',
  'host' => '127.0.0.1',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
  'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock',
);

Tags:

Sql Example