背景: 使用laravel项目的命令行惊现错误 php artisan companyCustomerStatisticsCommand
In Connection.php line 664:
could not find driver (SQL: select max(`customer_id`) as aggregate from `statistic_customer`)
排查: 1.浏览器直接访问项目,数据库均能正常访问 2.浏览器查看phpinfo(), 获取到php版本信息 PHP Version 7.2.11-2+ubuntu18.04.1+deb.sury.org+1 3.php -v查看php客户端版本 PHP 7.3.0RC3 (cli) (built: Oct 15 2018 11:37:12) ( NTS )
思考: php客户端根php-fpm版本不一致 phpinfo()可以看到php-fpm中已经加载mysql扩展. php命令行php -m | grep mysql无结果,故缺少php客户端版对应的mysql扩展php7.3-mysql
解决过程: sudo apt-get install php7.3-mysql