【发布时间】:2021-12-03 03:44:13
【问题描述】:
我正在尝试使用 Laravel 和 Sail 创建一个项目,但是当我尝试迁移或执行与项目数据库相关的任何操作(例如,播种)时出现错误。
更具体地说,当使用 artisan sail migrate 或任何相关内容时,我收到以下错误:
当DB_HOST=localhost 在我的.env 文件中时:
SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from information_schema.tables where table_schema = noway and table_name = migrations and table_type = 'BASE TABLE')
当DB_HOST=127.0.0.1 在我的.env 文件中时:
SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = noway and table_name = migrations and table_type = 'BASE TABLE')
我尝试过的:
- 将
DB_HOST更改为 localhost 和 127.0.0.1(网上最常见的答案,没有成功) - 确保 SQL 正在运行
- 正在清除
sail artisan migrate的缓存 -
./vendor/bin/sail down --rmi all -v删除所有图像和卷 - 更改用户名和密码并将它们放在 '' 或 "" 之间
以上都没有成功。
【问题讨论】:
标签: php mysql laravel web laravel-sail