PDO drivers missing on Ubuntu 16.04 with PHP 7.2.4

拟墨画扇 提交于 2020-01-14 14:24:51

问题


I wanted to try the latest version of PHP on Kubuntu 16.04, since then, it seems I can't use pdo with mysql.

When I launch php, I have the following warning:

PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/lib/php/20170718/pdo_mysql (/usr/lib/php/20170718/pdo_mysql: cannot open shared object file: No such file or directory), /usr/lib/php/20170718/pdo_mysql.so (/usr/lib/php/20170718/pdo_mysql.so: undefined symbol: pdo_parse_params)) in Unknown on line 0

I'm running

PHP 7.2.4-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Apr  5 2018 08:53:57) ( NTS )

I tried to fix with this solution : https://askubuntu.com/a/824505, but I've the same problem.

However, in the phpinfo, there's a driver found for PDO (mysql). When I check a php -m, PDO and pdo_mysql are found.

In the /usr/lib/php/20170718 and /usr/lib/php/20151012 folder, there is a pdo_mysql.so.

I don't really know what else to try. Thanks in advance for your help.


回答1:


sudo apt-get update
sudo apt-get install php7.2-pdo



回答2:


In my case I had updated from Ubuntu 16.04 to 18.04, thus PHP 7.0 to 7.2.

Turns out PHP 7.0 was still (partly) installed, and was the active PHP-FPM handler for Apache.

Commands I used to resolve this: (as root or via sudo)

service php7.0-fpm stop
apt-get remove php7.0*
service php7.2-fpm restart
service apache2 restart

Be sure to copy any INI changes you made from /etc/php/7.0 to /etc/php/7.2 though.



来源:https://stackoverflow.com/questions/49784177/pdo-drivers-missing-on-ubuntu-16-04-with-php-7-2-4

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!