1

when i write this command: php artisan migrate

enter image description here Laravel Provides Database migrations which don't work very well for me when i write this command: php artisan migrate it always give me this error

  • 1
    it seems you are not able to connect the database, are you sure the credentials right – Teoman Tıngır Mar 08 '20 at 13:40
  • Please include error messages as text rather than images. See https://stackoverflow.com/help/how-to-ask. – Calum Halpin Mar 08 '20 at 14:20
  • the error is : SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = ecom_db and table_name = migrations and table_type = 'BASE TABLE') – Adham Essam Mar 08 '20 at 14:28
  • The error says that PHP can’t connect to the MySQL instance.It your database credential are correct, then clear your config cache `php artisan config:cache` then run again `php artisan migrate` – STA Mar 08 '20 at 15:34

2 Answers2

0

Change the .env file from 127.0.0.1 to localhost fixed it.

DB_HOST=localhost

do config:cache after .env file change. php artisan config:cache

Dilip Hirapara
  • 14,810
  • 3
  • 27
  • 49
0

Ensure you have an .env file, and that the database related variables within have been set correctly.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password
James Clark
  • 1,285
  • 2
  • 9
  • 14