Unable to run console commands (Craft 3, MAMP) This was asked and solved previously, but for Craft 2, see Error Connecting To (MAMP Pro) Database in Console Command. Unable to make it work here.

In short, running console commands like ./craft abc in Craft 3 configured using MAMP gives

Craft isn’t installed yet!    

Exception 'craft\errors\DbConnectException' with message 'Craft CMS can’t connect to the database with the credentials in config/db.php.'

in /Users/stian/dev/site.no/vendor/craftcms/cms/src/db/Connection.php:179

Stack trace:
#0 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/Connection.php(996): craft\db\Connection-&gt;open()
#1 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/Connection.php(983): yii\db\Connection-&gt;getMasterPdo()
#2 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/mysql/QueryBuilder.php(380): yii\db\Connection-&gt;getSlavePdo()
#3 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/mysql/QueryBuilder.php(399): yii\db\mysql\QueryBuilder-&gt;supportsFractionalSeconds()
#4 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/mysql/QueryBuilder.php(57): yii\db\mysql\QueryBuilder-&gt;defaultTimeTypeMap()
#5 /Users/stian/dev/site.no/vendor/craftcms/cms/src/db/mysql/QueryBuilder.php(27): yii\db\mysql\QueryBuilder-&gt;init()
#6 /Users/stian/dev/site.no/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\db\mysql\QueryBuilder-&gt;init()
#7 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/QueryBuilder.php(116): yii\base\BaseObject-&gt;__construct(Array)
#8 /Users/stian/dev/site.no/vendor/craftcms/cms/src/db/mysql/Schema.php(71): yii\db\QueryBuilder-&gt;__construct(Object(craft\db\Connection), Array)
#9 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/Schema.php(249): craft\db\mysql\Schema-&gt;createQueryBuilder()
#10 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/Connection.php(836): yii\db\Schema-&gt;getQueryBuilder()
#11 /Users/stian/dev/site.no/vendor/yiisoft/yii2/db/Command.php(580): yii\db\Connection-&gt;getQueryBuilder()
#12 /Users/stian/dev/site.no/vendor/craftcms/cms/src/db/Command.php(142): yii\db\Command-&gt;update('{{%queue}}', Array, '[[timeUpdated]]...', Array)
#13 /Users/stian/dev/site.no/vendor/craftcms/cms/src/queue/Queue.php(507): craft\db\Command-&gt;update('{{%queue}}', Array, '[[timeUpdated]]...', Array, false)
#14 /Users/stian/dev/site.no/vendor/craftcms/cms/src/queue/Queue.php(449): craft\queue\Queue-&gt;_moveExpired()
#15 /Users/stian/dev/site.no/vendor/craftcms/cms/src/queue/Queue.php(95): craft\queue\Queue-&gt;reserve()
#16 /Users/stian/dev/site.no/vendor/craftcms/cms/src/queue/Command.php(82): craft\queue\Queue-&gt;run()
#17 [internal function]: craft\queue\Command-&gt;actionRun()
#18 /Users/stian/dev/site.no/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
#19 /Users/stian/dev/site.no/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction-&gt;runWithParams(Array)
#20 /Users/stian/dev/site.no/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller-&gt;runAction('run', Array)
#21 /Users/stian/dev/site.no/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller-&gt;runAction('run', Array)
#22 /Users/stian/dev/site.no/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module-&gt;runAction('queue/run', Array)
#23 /Users/stian/dev/site.no/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application-&gt;runAction('queue/run', Array)
#24 /Users/stian/dev/site.no/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application-&gt;runAction('queue/run', Array)
#25 /Users/stian/dev/site.no/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application-&gt;handleRequest(Object(craft\console\Request))
#26 /Users/stian/dev/site.no/craft(22): yii\base\Application-&gt;run()
#27 {main}


Ideas?
You might not have MAMP's PHP set as your CLI PHP. Have a look at this guide and see if it gets you further