laravel homestead环境链接mysql出错
后台登录,出现错误提示
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
端口默认是 3306
DB_PORT=3306
详见:
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
Exception trace:
1 DoctrineDBALDriverPDOException::("SQLSTATE[HY000] [2002] Connection refused")
2 PDOException::("SQLSTATE[HY000] [2002] Connection refused")
Please use the argument -v to see more details.