Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I can't add pgsql PDO Driver in MAMP on Mac Big Sur

I have installed MAMP and PostgreSQL with PGAdmin4, but I'm having some problems.

I'm getting a psql "command not found error" in my terminal. I have added export PATH=/Library/PostgreSQL/10/bin:$PATH into ~/.bash_profile, but whenever I reopen the terminal, I get the same error again.

Whenever I try to execute composer or php artisan in my Laravel project I get the below errors, but I'm still able to migrate database:

Warning: PHP Startup: Unable to load dynamic library 'pdo_pgsql' (tried: /usr/local/lib/php/pecl/20180731/pdo_pgsql (dlopen(/usr/local/lib/php/pecl/20180731/pdo_pgsql, 9): image not found)

Warning: PHP Startup: Unable to load dynamic library 'pgsql' (tried: /usr/local/lib/php/pecl/20180731/pgsql (dlopen(/usr/local/lib/php/pecl/20180731/pgsql, 9): image not found)

Getting a "driver not found" error whenever trying to browse the project and in PDO Drivers list in phpinfo(), mysql and sqlite available, but pgsql is not available.

MAMP
PostgreSQL 10
PHP: 7.3.21
OS: MAC Big Sur

like image 634
jalal uddin Avatar asked Nov 06 '22 04:11

jalal uddin


1 Answers

I had the same issue and when I looked in my php.ini file, I saw that my extensions folder was pointed to the wrong location:

extension_dir = "/Applications/MAMP/bin/php/php7.4.2/lib/php/extensions"

But I don't have a matching directory for php7.4.2 - I use php7.4.9, and confirmed the extension exists in that folder. To fix it for me, I just had to change the above line in my php.ini file to:

extension_dir = "/Applications/MAMP/bin/php/php7.4.9/lib/php/extensions"

And then all was good for me.

like image 118
Tammy Shipps Avatar answered Nov 14 '22 19:11

Tammy Shipps