mysql环境搭载后老出错_使用Docker在window10下搭建SWOFT开发环境,mysql连接错误

使用Docker在window10下搭建SWOFT开发环境,mysql连接错误

{

"code": 0,

"error": "(Swoft\\Db\\Exception\\DbException) Pool error is Create connection error(Dsn(mysql:dbname=test;host=127.0.0.1:13306) can not to connected!) file(/var/www/swoft/vendor/swoft/db/src/Connector/MySqlConnector.php) line (43) file=/var/www/swoft/vendor/swoft/connection-pool/src/AbstractPool.php line=250",

"file": "At /var/www/swoft/vendor/swoft/db/src/DB.php line 81",

"trace": "#0 /var/www/swoft/vendor/swoft/db/src/Query/Builder.php(3324): Swoft\\Db\\DB::connection('db.pool')

#1 /var/www/swoft/vendor/swoft/db/src/Query/Builder.php(2437): Swoft\\Db\\Query\\Builder->getConnection()

#2 /var/www/swoft/app/Http/Controller/OrderController.php(35): Swoft\\Db\\Query\\Builder->cursor()

#3 /var/www/swoft/vendor/swoft/stdlib/src/Helper/PhpHelper.php(54): App\\Http\\Controller\\OrderController->buy()

#4 /var/www/swoft/vendor/swoft/http-server/src/Middleware/DefaultMiddleware.php(75): Swoft\\Stdlib\\Helper\\PhpHelper::call(Array)

#5 /var/www/swoft/vendor/swoft/http-server/src/RequestHandler.php(73): Swoft\\Http\\Server\\Middleware\\DefaultMiddleware->process(Object(Swoft\\Http\\Message\\Request), Object(Swoft\\Http\\Server\\RequestHandler))

#6 /var/www/swoft/vendor/swoft/http-server/src/Middleware/ValidatorMiddleware.php(50): Swoft\\Http\\Server\\RequestHandler->handle(Object(Swoft\\Http\\Message\\Request))

#7 /var/www/swoft/vendor/swoft/http-server/src/RequestHandler.php(73): Swoft\\Http\\Server\\Middleware\\ValidatorMiddleware->process(Object(Swoft\\Http\\Message\\Request), Object(Swoft\\Http\\Server\\RequestHandler))

#8 /var/www/swoft/vendor/swoft/http-server/src/Middleware/UserMiddleware.php(54): Swoft\\Http\\Server\\RequestHandler->handle(Object(Swoft\\Http\\Message\\Request))

#9 /var/www/swoft/vendor/swoft/http-server/src/RequestHandler.php(73): Swoft\\Http\\Server\\Middleware\\UserMiddleware->process(Object(Swoft\\Http\\Message\\Request), Object(Swoft\\Http\\Server\\RequestHandler))

#10 /var/www/swoft/vendor/swoft/view/src/Middleware/ViewMiddleware.php(41): Swoft\\Http\\Server\\RequestHandler->handle(Object(Swoft\\Http\\Message\\Request))

#11 /var/www/swoft/vendor/swoft/http-server/src/RequestHandler.php(73): Swoft\\View\\Middleware\\ViewMiddleware->process(Object(Swoft\\Http\\Message\\Request), Object(Swoft\\Http\\Server\\RequestHandler))

#12 /var/www/swoft/app/Http/Middleware/FavIconMiddleware.php(45): Swoft\\Http\\Server\\RequestHandler->handle(Object(Swoft\\Http\\Message\\Request))

#13 /var/www/swoft/vendor/swoft/http-server/src/RequestHandler.php(73): App\\Http\\Middleware\\FavIconMiddleware->process(Object(Swoft\\Http\\Message\\Request), Object(Swoft\\Http\\Server\\RequestHandler))

#14 /var/www/swoft/vendor/swoft/http-server/src/HttpDispatcher.php(80): Swoft\\Http\\Server\\RequestHandler->handle(Object(Swoft\\Http\\Message\\Request))

#15 /var/www/swoft/vendor/swoft/http-server/src/Swoole/RequestListener.php(42): Swoft\\Http\\Server\\HttpDispatcher->dispatch(Object(Swoft\\Http\\Message\\Request), Object(Swoft\\Http\\Message\\Response))

#16 {main}"

}

尝试过检查mysql端口及配置,发现mysql在docker容器里运行正常。但是swoft程序无法正常连接到mysql。请问是不是docker容器间请求服务哪里设置不当的原因?Swoft的DB配置如下:

'db'=> [

'class' => Database::class,

'dsn' => 'mysql:dbname=test;host=127.0.0.1:13306',

'username' => 'root',

'password' => '123456',

'prefix' => 'vc_',

'charset' => 'utf8',

],

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值