laravel homestead环境链接mysql出错

发布于 2022-09-11 21:01:56 字数 343 浏览 32 评论 0

后台登录,出现错误提示

SQLSTATE[HY000] [2002] Connection refused (SQL: select * from admins where id = 1 limit 1)

.env配置

znspt.test(本地测试地址)

DB_CONNECTION=mysql
DB_HOST=znspt.test
DB_PORT=33060
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

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

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

发布评论

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

评论(2

失去的东西太少 2022-09-18 21:01:56

端口默认是 3306
DB_PORT=3306

详见:

萧瑟寒风 2022-09-18 21:01:56

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
端口配置3306
执行php artisan migrate
报如下错误:
IlluminateDatabaseQueryException : SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_schema.tables where table_schema = homestead and table_name = migrations)

at /Users/tangmoqi/code/znspt/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664

660|         // If an exception occurs when attempting to run a query, we'll format the error
661|         // message to include the bindings with SQL, which will make this exception a
662|         // lot more helpful to the developer instead of just the database's errors.
663|         catch (Exception $e) {

664| throw new QueryException(

665|                 $query, $this->prepareBindings($bindings), $e
666|             );
667|         }
668|

Exception trace:

1 DoctrineDBALDriverPDOException::("SQLSTATE[HY000] [2002] Connection refused")

  /Users/tangmoqi/code/znspt/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31

2 PDOException::("SQLSTATE[HY000] [2002] Connection refused")

  /Users/tangmoqi/code/znspt/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27

Please use the argument -v to see more details.

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