与TP5框架结合,报这个错误。PHP扩展已经打开,phpinfo中可查看。请问怎么解决

鸢北

PDOException: could not find driver in /www/wwwroot/henghui/thinkphp/library/think/db/Connection.php:295
Stack trace:

0 /www/wwwroot/henghui/thinkphp/library/think/db/Connection.php(295): PDO->__construct('mysql:host=120....', 'henghui', 'YjRNm7pB7ix3jPK...', Array)

1 /www/wwwroot/henghui/thinkphp/library/think/db/Connection.php(995): think\db\Connection->connect()

2 /www/wwwroot/henghui/thinkphp/library/think/db/Connection.php(348): think\db\Connection->initConnect(false)

3 /www/wwwroot/henghui/thinkphp/library/think/db/connector/Mysql.php(65): think\db\Connection->query('SHOW COLUMNS FR...', Array, false, true)

4 /www/wwwroot/henghui/thinkphp/library/think/db/Query.php(1921): think\db\connector\Mysql->getFields('fa_device')

5 /www/wwwroot/henghui/thinkphp/library/think/db/Query.php(1969): think\db\Query->getTableInfo('fa_device', 'type')

6 /www/wwwroot/henghui/thinkphp/library/think/db/Query.php(1975): think\db\Query->getFieldsType('fa_device')

7 /www/wwwroot/henghui/thinkphp/library/think/db/Builder.php(270): think\db\Query->getFieldsBind('fa_device')

8 /www/wwwroot/henghui/thinkphp/library/think/db/Builder.php(240): think\db\Builder->buildWhere(Array, Array)

9 /www/wwwroot/henghui/thinkphp/library/think/db/Builder.php(719): think\db\Builder->parseWhere(Array, Array)

10 /www/wwwroot/henghui/thinkphp/library/think/db/Query.php(2462): think\db\Builder->select(Array)

11 /www/wwwroot/henghui/thinkphp/library/think/db/Query.php(441): think\db\Query->getPdo()

12 /www/wwwroot/henghui/thinkphp/library/think/db/Query.php(576): think\db\Query->value('COUNT(*) AS tp_...', 0, true)

13 /www/wwwroot/henghui/thinkphp/library/think/db/Query.php(551): think\db\Query->aggregate('COUNT', '*', true)

14 /www/wwwroot/henghui/application/push/controller/Events.php(32): think\db\Query->count()

15 [internal function]: app\push\controller\Events::onMessage('7f00000108fe000...', '{"pak_sn":123,"...')

16 /www/wwwroot/henghui/vendor/workerman/gateway-worker/src/BusinessWorker.php(404): call_user_func('app\push\contro...', '7f00000108fe000...', '{"pak_sn":123,"...')

17 /www/wwwroot/henghui/vendor/workerman/workerman/Connection/TcpConnection.php(656): GatewayWorker\BusinessWorker->onGatewayMessage(Object(Workerman\Connection\AsyncTcpConnection), Array)

18 /www/wwwroot/henghui/vendor/workerman/workerman/Events/Select.php(292): Workerman\Connection\TcpConnection->baseRead(Resource id #155)

19 /www/wwwroot/henghui/vendor/workerman/workerman/Worker.php(2408): Workerman\Events\Select->loop()

20 /www/wwwroot/henghui/vendor/workerman/gateway-worker/src/BusinessWorker.php(197): Workerman\Worker->run()

21 /www/wwwroot/henghui/vendor/workerman/workerman/Worker.php(1541): GatewayWorker\BusinessWorker->run()

22 /www/wwwroot/henghui/vendor/workerman/workerman/Worker.php(1371): Workerman\Worker::forkOneWorkerForLinux(Object(GatewayWorker\BusinessWorker))

23 /www/wwwroot/henghui/vendor/workerman/workerman/Worker.php(1345): Workerman\Worker::forkWorkersForLinux()

24 /www/wwwroot/henghui/vendor/workerman/workerman/Worker.php(546): Workerman\Worker::forkWorkers()

25 /www/wwwroot/henghui/application/push/controller/start/normal/Linuxgate.php(68): Workerman\Worker::runAll()

26 [internal function]: app\push\controller\start\normal\Linuxgate->__construct()

27 /www/wwwroot/henghui/thinkphp/library/think/App.php(359): ReflectionClass->newInstanceArgs(Array)

28 /www/wwwroot/henghui/thinkphp/library/think/Loader.php(479): think\App::invokeClass('app\push\contro...')

29 /www/wwwroot/henghui/thinkphp/library/think/App.php(580): think\Loader::controller('start.normal.li...', 'controller', false, 'Error')

30 /www/wwwroot/henghui/thinkphp/library/think/App.php(456): think\App::module(Array, Array, true)

31 /www/wwwroot/henghui/thinkphp/library/think/App.php(139): think\App::exec(Array, Array)

32 /www/wwwroot/henghui/thinkphp/start.php(19): think\App::run()

33 /www/wwwroot/henghui/linux-port-8090.php(26): require('/www/wwwroot/he...')

34 {main}

Worker[7662] process terminated
worker[DBusinessWorker:7662] exit with status 64000
^CWorkerman[linux-port-8090.php] stopping ...
Workerman[linux-port-8090.php] has been stopped
截图

2923 1 0
1个回答

six

workeman是基于php-cli运行的,看起来是php-cli没安装 pdo或 pdo-mysql扩展。
截图里只能证明php-fpm 或者 apache安装了 pdo-mysql扩展,不代表 php-cli安装了 pdo-mysql扩展。

要看php-cli是否安装了扩展运行命令 php -m | grep pdo
如果没安装,找到php-cli所使用的 php.ini文件 命令为 php --ini,然后打开php.ini把对应扩展加上去。

  • 鸢北 2020-11-10

    感谢大佬指点,我这边是用的ubuntu 16.04 在安装系统的时候,系统默认安装上了PHP7.2的版本,里边少了几个扩展。而网站是用的宝塔面板中的php环境,之前装的php扩展,都放到了php7.3当中,所以导致这个问题。现在已经将宝塔中的 php 命令作为全局变量,将之前的PHP7.2卸载。完美解决

年代过于久远,无法发表回答
×
🔝