AWS上的Cron Job Laravel,数据库查询异常无此类文件或目录

时间:2019-02-17 12:31:09

标签: php mysql amazon-ec2 cron

我正在尝试在AWS EC2实例上运行cron作业。 cron作业启动,但是每次尝试访问mysql数据库时,我都会得到查询异常,这是stacktrace:

SQLSTATE[HY000] [2002] No such file or directory (SQL: select * from 
`na_activity`) {"exception":"[object] 
(Illuminate\\Database\\QueryException(code: 2002): SQLSTATE[HY000] 
[2002] No such file or directory (SQL: select * from `na_activity`) at /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connecti   on.php:664, Doctrine\\DBAL\\Driver\\PDOException(code: 2002): 
SQLSTATE[HY000] [2002] No such file or directory at /var/app/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:31, PDOException(code: 2002): SQLSTATE[HY000] [2002] No such file or directory at /var/app/current/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php:27)

[stacktrace]
#0 /var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(624): Illuminate\\Database\\Connection->runQueryCallback('select * from `...', Array, Object(Closure))
#1/var/app/current/vendor/laravel/framework/src/Illuminate/Database/Connection.php(333): Illuminate\\Database\\Connection->run('select * from `...', Array, Object(Closure))
#2/var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1719): Illuminate\\Database\\Connection->select('select * from `...', Array, true)
#3/var/app/current/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php(1704): Illuminate\\Database\\Query\\Builder->runSelect()
#4/var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(481): Illuminate\\Database\\Query\\Builder->get(Array)
#5/var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php(465): Illuminate\\Database\\Eloquent\\Builder->getModels(Array)
#6/var/app/current/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php(360): Illuminate\\Database\\Eloquent\\Builder->get(Array)
#7/var/app/current/app/Http/Controllers/Frontend/ActivityController.php(12 
8): Illuminate\\Database\\Eloquent\\Model::all()
#8 /var/app/current/app/Console/Kernel.php(348): App\\Http\\Controllers\\Frontend\\ActivityController::saveBokunActivityPrice()
#9 /var/app/current/app/Console/Kernel.php(84):App\\Console\\Kernel::syncBokunPrices()
#10 [internal function]: App\\Console\\Kernel->App\\Console\\{closure()
#11/var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Object(Closure), Array)
#12/var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(75): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#13/var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Object(Closure), Object(Closure))
#14/var/app/current/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Object(Closure), Array, NULL)
#15/var/app/current/vendor/laravel/framework/src/Illuminate/Console/Scheduling/CallbackEvent.php(74): Illuminate\\Container\\Container->call(Object(Closure), Array)
#16/var/app/current/vendor/laravel/framework/src/Illuminate/Console/Scheduling/ScheduleRunCommand.php(59): Illuminate\\Console\\Scheduling\\CallbackEvent->run(Object(Illuminate\\Foundation\\Application))
#17 [internal function]:Illuminate\\Console\\Scheduling\\ScheduleRunCommand->handle()
#18/var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(29): call_user_func_array(Array, Array)
#19/var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(87): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#20/var/app/current/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(31): Illuminate\\Container\\BoundMethod::callBoundMethod(Object(Illuminate\\Foundation\\Application), Array, Object(Closure))
#21/var/app/current/vendor/laravel/framework/src/Illuminate/Container/Container.php(549): Illuminate\\Container\\BoundMethod::call(Object(Illuminate\\Foundation\\Application), Array, Array, NULL)
#22/var/app/current/vendor/laravel/framework/src/Illuminate/Console/Command.php(183): Illuminate\\Container\\Container->call(Array)
#23 /var/app/current/vendor/symfony/console/Command/Command.php(255):Illuminate\\Console\\Command->execute(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#24/var/app/current/vendor/laravel/framework/src/Illuminate/Console/Command.php(170): Symfony\\Component\\Console\\Command\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Illuminate\\Console\\OutputStyle))
#25 /var/app/current/vendor/symfony/console/Application.php(953):Illuminate\\Console\\Command->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#26 /var/app/current/vendor/symfony/console/Application.php(248):Symfony\\Component\\Console\\Application->doRunCommand(Object(Illuminate\\Console\\Scheduling\\ScheduleRunCommand), Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#27 /var/app/current/vendor/symfony/console/Application.php(148):Symfony\\Component\\Console\\Application->doRun(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#28/var/app/current/vendor/laravel/framework/src/Illuminate/Console/Application.php(88): Symfony\\Component\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#29/var/app/current/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Illuminate\\Console\\Application->run(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#30 /var/app/current/artisan(35):Illuminate\\Foundation\\Console\\Kernel->handle(Object(Symfony\\Component\\Console\\Input\\ArgvInput), Object(Symfony\\Component\\Console\\Output\\ConsoleOutput))
#31 {main}"}

有什么想法我需要做什么? “在这种情况下,没有这样的文件或目录”是什么意思?找不到数据库吗?如果是这种情况,我该怎么解决?

0 个答案:

没有答案