部署到线上后无法登录,报错
问题描述
程序代码
<?php
return [
'default' => 'mysql',
'connections' => [
'mysql' => [
'driver' => 'mysql',
'host' => 'localhost',
'port' => '3306',
'database' => 'webman_admin',
'username' => 'webman_admin',
'password' => '123456',
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'prefix' => '',
'strict' => true,
'engine' => null,
],
],
];
报错信息
PDOException: SQLSTATE[HY000] [2002] No such file or directory in /app/vendor/illuminate/database/Connectors/Connector.php:65
Stack trace:
#0 /app/vendor/illuminate/database/Connectors/Connector.php(65): PDO->__construct()
#1 /app/vendor/illuminate/database/Connectors/Connector.php(83): Illuminate\Database\Connectors\Connector->createPdoConnection()
#2 /app/vendor/illuminate/database/Connectors/Connector.php(49): Illuminate\Database\Connectors\Connector->tryAgainIfCausedByLostConnection()
#3 /app/vendor/illuminate/database/Connectors/MySqlConnector.php(24): Illuminate\Database\Connectors\Connector->createConnection()
#4 /app/vendor/illuminate/database/Connectors/ConnectionFactory.php(184): Illuminate\Database\Connectors\MySqlConnector->connect()
#5 [internal function]: Illuminate\Database\Connectors\ConnectionFactory->Illuminate\Database\Connectors\{closure}()
#6 /app/vendor/illuminate/database/Connection.php(1275): call_user_func()
#7 /app/vendor/illuminate/database/Connection.php(1311): Illuminate\Database\Connection->getPdo()
#8 /app/vendor/illuminate/database/Connection.php(521): Illuminate\Database\Connection->getReadPdo()
#9 /app/vendor/illuminate/database/Connection.php(416): Illuminate\Database\Connection->getPdoForSelect()
#10 /app/vendor/illuminate/database/Connection.php(788): Illuminate\Database\Connection->Illuminate\Database\{closure}()
#11 /app/vendor/illuminate/database/Connection.php(934): Illuminate\Database\Connection->runQueryCallback()
#12 /app/vendor/illuminate/database/Connection.php(914): Illuminate\Database\Connection->tryAgainIfCausedByLostConnection()
#13 /app/vendor/illuminate/database/Connection.php(758): Illuminate\Database\Connection->handleQueryException()
#14 /app/vendor/illuminate/database/Connection.php(424): Illuminate\Database\Connection->run()
#15 /app/vendor/illuminate/database/Query/Builder.php(2736): Illuminate\Database\Connection->select()
#16 /app/vendor/illuminate/database/Query/Builder.php(2724): Illuminate\Database\Query\Builder->runSelect()
#17 /app/vendor/illuminate/database/Query/Builder.php(3278): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#18 /app/vendor/illuminate/database/Query/Builder.php(2725): Illuminate\Database\Query\Builder->onceWithColumns()
#19 /app/vendor/illuminate/database/Eloquent/Builder.php(717): Illuminate\Database\Query\Builder->get()
#20 /app/vendor/illuminate/database/Eloquent/Builder.php(701): Illuminate\Database\Eloquent\Builder->getModels()
#21 /app/vendor/illuminate/database/Concerns/BuildsQueries.php(296): Illuminate\Database\Eloquent\Builder->get()
#22 /app/plugin/admin/app/controller/AccountController.php(75): Illuminate\Database\Eloquent\Builder->first()
#23 /app/vendor/workerman/webman-framework/src/App.php(319): plugin\admin\app\controller\AccountController->login()
#24 /app/vendor/workerman/webman-framework/src/App.php(349): Webman\App::Webman\{closure}()
#25 /app/plugin/admin/app/middleware/AccessControl.php(47): Webman\App::Webman\{closure}()
#26 /app/vendor/workerman/webman-framework/src/App.php(341): plugin\admin\app\middleware\AccessControl->process()
#27 /app/vendor/workerman/webman-framework/src/App.php(141): Webman\App::Webman\{closure}()
#28 /app/vendor/workerman/workerman/Connection/TcpConnection.php(646): Webman\App->onMessage()
#29 [internal function]: Workerman\Connection\TcpConnection->baseRead()
#30 /app/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()
#31 /app/vendor/workerman/workerman/Worker.php(1629): Workerman\Events\Event->loop()
#32 /app/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux()
#33 /app/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
#34 /app/vendor/workerman/workerman/Worker.php(560): Workerman\Worker::forkWorkers()
#35 /app/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#36 /app/start.php(4): support\App::run()
#37 {main}
Next Illuminate\Database\QueryException: SQLSTATE[HY000] [2002] No such file or directory (Connection: plugin.admin.mysql, SQL: select * from `wa_admins` where `username` = leeseean limit 1) in /app/vendor/illuminate/database/Connection.php:795
Stack trace:
#0 /app/vendor/illuminate/database/Connection.php(934): Illuminate\Database\Connection->runQueryCallback()
#1 /app/vendor/illuminate/database/Connection.php(914): Illuminate\Database\Connection->tryAgainIfCausedByLostConnection()
#2 /app/vendor/illuminate/database/Connection.php(758): Illuminate\Database\Connection->handleQueryException()
#3 /app/vendor/illuminate/database/Connection.php(424): Illuminate\Database\Connection->run()
#4 /app/vendor/illuminate/database/Query/Builder.php(2736): Illuminate\Database\Connection->select()
#5 /app/vendor/illuminate/database/Query/Builder.php(2724): Illuminate\Database\Query\Builder->runSelect()
#6 /app/vendor/illuminate/database/Query/Builder.php(3278): Illuminate\Database\Query\Builder->Illuminate\Database\Query\{closure}()
#7 /app/vendor/illuminate/database/Query/Builder.php(2725): Illuminate\Database\Query\Builder->onceWithColumns()
#8 /app/vendor/illuminate/database/Eloquent/Builder.php(717): Illuminate\Database\Query\Builder->get()
#9 /app/vendor/illuminate/database/Eloquent/Builder.php(701): Illuminate\Database\Eloquent\Builder->getModels()
#10 /app/vendor/illuminate/database/Concerns/BuildsQueries.php(296): Illuminate\Database\Eloquent\Builder->get()
#11 /app/plugin/admin/app/controller/AccountController.php(75): Illuminate\Database\Eloquent\Builder->first()
#12 /app/vendor/workerman/webman-framework/src/App.php(319): plugin\admin\app\controller\AccountController->login()
#13 /app/vendor/workerman/webman-framework/src/App.php(349): Webman\App::Webman\{closure}()
#14 /app/plugin/admin/app/middleware/AccessControl.php(47): Webman\App::Webman\{closure}()
#15 /app/vendor/workerman/webman-framework/src/App.php(341): plugin\admin\app\middleware\AccessControl->process()
#16 /app/vendor/workerman/webman-framework/src/App.php(141): Webman\App::Webman\{closure}()
#17 /app/vendor/workerman/workerman/Connection/TcpConnection.php(646): Webman\App->onMessage()
#18 [internal function]: Workerman\Connection\TcpConnection->baseRead()
#19 /app/vendor/workerman/workerman/Events/Event.php(193): EventBase->loop()
#20 /app/vendor/workerman/workerman/Worker.php(1629): Workerman\Events\Event->loop()
#21 /app/vendor/workerman/workerman/Worker.php(1423): Workerman\Worker::forkOneWorkerForLinux()
#22 /app/vendor/workerman/workerman/Worker.php(1397): Workerman\Worker::forkWorkersForLinux()
#23 /app/vendor/workerman/workerman/Worker.php(560): Workerman\Worker::forkWorkers()
#24 /app/vendor/workerman/webman-framework/src/support/App.php(131): Workerman\Worker::runAll()
#25 /app/start.php(4): support\App::run()
#26 {main}
2个回答
年代过于久远,无法发表回答
重启过没有
重启了
MYSQL在宿主机就写宿主机与DOCKER同网段的IP地址,不要写localhost
具体怎么写啊。docker同网段的ip地址是多少
用这个,
host.docker.internal