1

I have used laravel before when it was 5.4 and I could easily connect to database, Now I want to work in a new project. try to connect to database and get this error.

  Illuminate\Database\QueryException  : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = todo and table_name = migrations)

I have tried every single trick I have found on stackoverflow. NONE worked. Why is this happening? this is my connection.

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=todo
DB_USERNAME=root
DB_PASSWORD=''
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62

2 Answers2

0

Try defining the DB_HOST with the actual ip address instead like

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=todo
DB_USERNAME=root
DB_PASSWORD=''
skribe
  • 3,595
  • 4
  • 25
  • 36
0

Are you running it on VM? If that case then try to point the DB_HOST to the right IP address of your Xampp SQL and then do php artisan config:cache & config:clear

GTHell
  • 603
  • 1
  • 8
  • 20