Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用Docker Compose在window10下搭建swoft开发环境,mysql连接错误 #1082

Open
akrick opened this issue Nov 4, 2019 · 4 comments
Labels

Comments

@akrick
Copy link

akrick commented Nov 4, 2019

{
"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}"
}

其中DB的配置如下:

'db'=> [
'class' => Database::class,
'dsn' => 'mysql:dbname=test;host=127.0.0.1:13306',
'username' => 'root',
'password' => '123456',
'prefix' => 'vc_',
'charset' => 'utf8',
],
@inhere
Copy link
Member

inhere commented Nov 4, 2019

使用 docker compose, mysql 并不在同一个容器里。

host=127.0.0.1:13306 需改为 host=mysql:13306

@akrick
Copy link
Author

akrick commented Nov 19, 2019

使用 docker compose, mysql 并不在同一个容器里。

host=127.0.0.1:13306 需改为 host=mysql:13306

修改了之后好像还是没能连上

Pool error is Create connection error(Dsn(mysql:dbname=test;host=mysql: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 At /var/www/swoft/vendor/swoft/db/src/DB.php line 81

mysql启动报错:
mysql-srv exited with code 2

@inhere
Copy link
Member

inhere commented Nov 19, 2019

:( db启动失败了 肯定连不上啊

@nanyounanyounan
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants