mercredi 3 juin 2020

How to fix SQLSTATE[HY000] [2002] No such file or directory - Laravel Error [duplicate]

after I moved my code to the production server, it starts showing error on every SQL command. On Localhost it was working fine.

I checked the connection, it is working fine, but after running any query it shows error.

The connection is established and proved by this Route (it works):

Route::get('/db-test', function() {
   if(DB::connection()->getDatabaseName()){
      echo "connected sucessfully to database" . DB::connection()->getDatabaseName();
   }
});

But when I try to run any query

Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from `admin` where `email` = admin@gmail.com limit 1)

this is my env

DB_CONNECTION=mysql
DB_HOST=**HOSTNAME***
DB_PORT=3306
DB_DATABASE=******
DB_USERNAME=******
DB_PASSWORD=******
DB_SOCKET=/tmp/mysql.sock


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire