查询工作正常,但迁移

发布于 2025-02-13 23:46:52 字数 695 浏览 0 评论 0原文

我正在使用 Laravel 9 / Laravel Sail < / strong>进行一个小型项目。我有一个奇怪的错误。我的应用程序查询效果很好,可以使用雄辩选择,更新,插入,插入,也可以使用雄辩。一切都很好。

现在,我尝试创建一个新的迁移,并尝试使用通常的php Arisan Migrate我收到一个错误消息:

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')

但是通过应用程序,它可以正常连接到数据库,因为插入和选择,更新

问题就是我尝试迁移时,这很奇怪。

我的环境:

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

小ぇ时光︴ 2025-02-20 23:46:52

如果您使用的是Laravel帆,则应该运行:

sail artisan migrate

而不是:

php artisan migrate

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

sail artisan migrate

instead of:

php artisan migrate
后知后觉 2025-02-20 23:46:52
  • 您可以尝试设置db_host = localhost
  • ,也可以是db_host = 0.0.0.0
  • 下一个执行

php工匠配置:清除

此命令将帮助您,清除缓存的配置

  • ,然后您可以运行迁移

php arisan迁移

  • 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文