Home > Enterprise >  Queries works Fine but the migration
Queries works Fine but the migration

Time:07-09

I'm working on a small project using Laravel 9 / Laravel Sail. I have a weird error. my application queries works fine I can select, update, insert with no problem using Eloquent also. Everything is good.

Now I try to created a new migration and I try to push the migration using the usual php arisan migrate I'm getting an error message :

SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for mysql failed: Temporary failure in name resolution (SQL: select * from information_schema.tables where table_schema = project and table_name = migrations and table_type = 'BASE TABLE')

But by application works fine its connected to the database as I'm inserting and selecting, updating

the problem is just when I try to migrate which is weird.

my env :

DB_CONNECTION=mysql
DB_HOST=mysql
DB_PORT=3306
DB_DATABASE=project
DB_USERNAME=username
DB_PASSWORD=password

CodePudding user response:

If you're using Laravel Sail, you should run:

sail artisan migrate

instead of:

php artisan migrate

CodePudding user response:

  • you can try set DB_HOST=localhost
  • or it can be DB_HOST=0.0.0.0
  • next execute the

php artisan config:clear

this command will help you, clear the cached config

  • then you can run your migration

php arisan migrate

  • Related