Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tarif_haque's avatar

Unable to load dynamic library 'pdo_mysql'

Hi, I'm just started learning PHP. And I am using the built-in HTTP server on Mac (Monterey 12.4).

When trying to connect with the mySQL database with PDO it shows:

could not find driver

I uncommented this line on the php.ini extension=pdo_mysql

But now the server shows:

PHP Warning: PHP Startup: Unable to load dynamic library 'pdo_mysql' (tried: /usr/local/lib/php/pecl/20190902/pdo_mysql (dlopen(/usr/local/lib/php/pecl/20190902/pdo_mysql, 0x0009): tried: '/usr/local/lib/php/pecl/20190902/pdo_mysql' (no such file)), /usr/local/lib/php/pecl/20190902/pdo_mysql.so (dlopen(/usr/local/lib/php/pecl/20190902/pdo_mysql.so, 0x0009): tried: '/usr/local/lib/php/pecl/20190902/pdo_mysql.so' (no such file))) in Unknown on line 0

My understanding is (please correct me if I'm wrong) pdo_mysql is not installed in the PHP extension directory /usr/local/lib/php/pecl/20190902/

Is it possible to check if pdo_mysql is installed in any other directory?

Please let me know how I can solve it please.

0 likes
10 replies
Jonjie's avatar

Try to comment that line with the extension=pdo_mysql using semi colon ;. Then after editing your php.ini file, restart your server.

tarif_haque's avatar

Thanks, @Jonjie Yes that will stop the error message but my code will not work as PDO is not getting enabled. I tried that.

So I need help so that pdo_mysql works properly...

tonny007's avatar

hello people, i have the same problem. help please.

azimidev's avatar

Try

php -m | grep pdo_mysql

to see if pdo extension has been installed in your system. if not then you should install it. then Install the pdo_mysql extension

sudo pecl install pdo_mysql

Enable the extension in your php.ini file:

extension=pdo_mysql.so

and restart your server:

sudo service apache2 restart
warpig's avatar

my pdo_mysql is installed but i have this same problem.

running php -i

PDO

PDO support => enabled
PDO drivers => mysql

pdo_mysql

PDO Driver for MySQL => enabled
Client API version => mysqlnd 8.1.2-1ubuntu2.14

Please or to participate in this conversation.