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

阅读 4.3k
2 个回答

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.

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题