无法加载动态库 'pdo_mysql.so',因为将 php 版本升级到 7.4

Unable to load dynamic library 'pdo_mysql.so' because upgrade php version to 7.4

我制作了一些 PHP 应用程序并使用 PDO。 一切都很好,直到我删除 --purge PHP 7.2 并安装 PHP 7.4.

程序是 运行 但显示“找不到驱动程序”。

像往常一样安装所有模块,在Ubuntu中出现类似这样的错误:

命令:

#php -v

结果:

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /usr/lib/php/20190902/pdo_mysql.so.so (/usr/lib/php/20190902/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP 7.4.16 (cli) (built: Mar  5 2021 07:54:20) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.16, Copyright (c), by Zend Technologies

命令:

# php -i |grep PDO

结果:

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/20190902/pdo_mysql.so (/usr/lib/php/20190902/pdo_mysql.so: undefined symbol: mysqlnd_allocator), /usr/lib/php/20190902/pdo_mysql.so.so (/usr/lib/php/20190902/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PDO
PDO support => enabled
PDO drivers => mysql, pgsql, sqlite
PDO Driver for MySQL => enabled
PDO Driver for PostgreSQL => enabled
PDO Driver for SQLite 3.x => enabled

在我的info.php

Loaded Configuration File   /etc/php/7.4/fpm/php.ini

在我的终端

Loaded Configuration File => /etc/php/7.4/cli/php.ini

所以我在 /etc/php/7.4/cli/php.ini 中进行了编辑。 我错了吗?有人可以给我一个建议吗?谢谢。

我通过确保安装了软件包解决了这个问题:sudo apt-get install php7.4-mysql

实物如图info.php:

Loaded Configuration File   /etc/php/7.4/fpm/php.ini

所以,我完成了在 fpm 中配置 php.ini 的问题。