phpinfo()下的php版本和php -v的不一致导致mysql 数据库操作could not find driver

背景:

laravel使用定时任务时,导致部分mysql操作失败

[2018-07-31 01:06:01] local.ERROR: could not find driver (SQL: select `identity` from `users` where `id` = 8 limit 1) {"exception":"[object] (Illuminate\\Database\\QueryException(code: 0): could not find driver (SQL: select `identity` from `users` where `id` = 8 limit 1) at /var/www/html/tangtuan-laravel/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 0): could not find driver at /var/www/html/tangtuan-laravel/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:67)

1.数据库代码使用请求形式触发时,运行正常。说明不是代码问题。

2.按照网上的解决方法增加了 php_pdo_mysql.dll 扩展,还是不行。

3.phpinfo()下的php版本和php -v的不一致


PHP 7.1.16-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Apr  5 2018 08:47:00) ( NTS )

查找7.1:root@iZuf62j52yzryhj2henk81Z:~# dpkg -l | grep php7.1

删除7.1:root@iZuf62j52yzryhj2henk81Z:~# apt-get autoremove php7.1

重启服务器后,定时任务日志打印正常!

猜你喜欢

转载自blog.csdn.net/zj328316760/article/details/81296712