Yet another PDO could not find driver issue

Mike Willis asked:

I’ve been working for the last two nights to set up my own LEMP server on Amazon ec2. I’m not a server expert so it’s been slow going, and the latest error “could not find driver” is given when attempting to create the new PDO object.

I’ve read what seems like dozens of threads about this error, and unfortunately none of the fixes seem to work for me. For the most part they all say I have to install php-mysql – but of course that’s not available:

$ sudo yum install php-mysql
Last metadata expiration check: 0:22:54 ago on Sat 17 Aug 2019 02:26:41 AM UTC.
No match for argument: php-mysql
Error: Unable to find a match

Meanwhile, phpinfo() seems to report that a driver is installed??

MySQL driver for PDO    George Schlossnagle, Wez Furlong, Ilia Alshanetsky, Johannes Schlueter

But under the PDO section of phpinfo() it says:

PDO drivers     odbc, sqlite

So I suppose the mysql driver really is missing? Leaving me at the same spot – finding it and installing it… But how to find the right one for my setup? I tried using yum to search but that failed (big surprise):

$ yum search php-
Red Hat Update Infrastructure 3 Client Configuration Server 8                                                                   0.0  B/s |   0  B     00:00
Error: Failed to synchronize cache for repo 'rhui-client-config-server-8'

Googling that error got me lost in another hundred or so threads, none of which helped..

Can anyone point me in the right direction? I imagine there’s a simple command I need to run that’s particular to my setup, I just need to figure out what it is..

Some other things I’ve tried:

  • run a php script from the linux command prompt to verify that the problem
    exists there: it does
  • check php.ini settings (they seem good, I’ll paste them below)
  • check /etc/php-fpm.d/www.conf settings (these also seem good, will paste below)

Here’s my various OS details:

$ cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.0 (Ootpa)"
PRETTY_NAME="Red Hat Enterprise Linux 8.0 (Ootpa)"
REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"

$ php -v
PHP 7.2.11 (cli) (built: Oct  9 2018 15:09:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

$ nginx -v
nginx version: nginx/1.14.1

$ mysql --version
mysql  Ver 8.0.17 for Linux on x86_64 (Source distribution)

and some excerpts from php.ini:

; Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off"


; If mysqlnd is used: Number of cache slots for the internal result set cache
pdo_mysql.cache_size = 2000

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.

excerpts from /etc/php-fpm.d/www.conf:

user = nginx
group = nginx

Hope that’s enough info – thank you in advance for any help!

My answer:

The PHP PDO MySQL driver is in the package named php-mysqlnd. Install this package, then restart the php-fpm service.

[[email protected] ~]# dnf info php-mysqlnd
Updating Subscription Management repositories.
Last metadata expiration check: 0:08:40 ago on Sat 17 Aug 2019 01:48:02 AM EDT.
Installed Packages
Name         : php-mysqlnd
Version      : 7.2.11
Release      : 1.module+el8+2561+1aca3413
Arch         : x86_64
Size         : 451 k
Source       : php-7.2.11-1.module+el8+2561+1aca3413.src.rpm
Repo         : @System
From repo    : rhel-8-for-x86_64-appstream-rpms
Summary      : A module for PHP applications that use MySQL databases
URL          :
License      : PHP
Description  : The php-mysqlnd package contains a dynamic shared object that
             : will add MySQL database support to PHP. MySQL is an
             : object-relational database management system. PHP is an
             : HTML-embeddable scripting language. If you need MySQL support for
             : PHP applications, you will need to install this package and the
             : php package.
             : This package use the MySQL Native Driver

[[email protected] ~]# 

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.