It's a common problem on a Mac, with MAMP, but also with other packaged environments.
The problem is that php in MAMP uses a non-standard php.ini location, so php-cli (used by oil) which uses the default in /etc will use the wrong one. Result of this is that for example the extensions and modules aren't loaded so you miss all database connectivity.
Quickest solution is to find which php.ini is used by MAMP, and change /etc/php.ini so that it is a symlink to that file, to ensure both use the same ini file.