Answers.Body: <p>You might not have MAMP's PHP set as your CLI PHP. <a href="https://craftcms.com/guides/mamp-with-composer-and-mysql-on-the-command-line" rel="nofollow noreferrer">Have a look at this guide</a> and see if it gets you further</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-13T16:24:13.477Z
Answers.LastActivityDate: 2019-03-13T16:24:13.477Z
Answers.UserDisplayName: Oli
Answers.Body: <p>I was able to fix this on my local MAMP installation by following the instructions for making MAMP play nicely with Craft in <a href="https://craftcms.com/guides/mamp-with-composer-and-mysql-on-the-command-line" rel="nofollow noreferrer">this guide</a>, then executing the command <code>chmod a+x craft</code> from <a href="https://nystudio107.com/blog/exploring-the-craft-cms-3-console-command-line-interface-cli" rel="nofollow noreferrer">this tutorial</a>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-09T05:04:03.237Z
Answers.LastActivityDate: 2020-03-09T05:04:03.237Z
Answers.UserDisplayName: kmgdev
Answers.Body: <p>Try with <code>php craft ..</code> instead of <code>./craft ...</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-13T17:27:12.747Z
Answers.LastActivityDate: 2019-03-13T17:27:12.747Z
Answers.UserDisplayName: Maxime Lafrenière
Body: <p>This was asked and solved previously, but for Craft 2, see <a href="https://craftcms.stackexchange.com/questions/12557/error-connecting-to-mamp-pro-database-in-console-command">Error Connecting To (MAMP Pro) Database in Console Command</a>. Unable to make it work here.</p>
  
  <p>In short, running console commands like <code>./craft abc</code> in Craft 3 configured using MAMP gives</p>
  
  <pre><code>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}
  </code></pre>
  
  <p>Ideas?</p>
  
Tags: <craft3><error-message><console>
Title: Unable to run console commands (Craft 3, MAMP)
ThreadText: # Unable to run console commands (Craft 3, MAMP)
  
  (Asked by: username_0 on 2019-03-13)
  
  This was asked and solved previously, but for Craft 2, see [Error Connecting To (MAMP Pro) Database in Console Command](https://craftcms.stackexchange.com/questions/12557/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/username_0/dev/site.no/vendor/craftcms/cms/src/db/Connection.php:179
  
  Stack trace:
  #0 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/Connection.php(996): craft\db\Connection->open()
  #1 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/Connection.php(983): yii\db\Connection->getMasterPdo()
  #2 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/mysql/QueryBuilder.php(380): yii\db\Connection->getSlavePdo()
  #3 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/mysql/QueryBuilder.php(399): yii\db\mysql\QueryBuilder->supportsFractionalSeconds()
  #4 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/mysql/QueryBuilder.php(57): yii\db\mysql\QueryBuilder->defaultTimeTypeMap()
  #5 /Users/username_0/dev/site.no/vendor/craftcms/cms/src/db/mysql/QueryBuilder.php(27): yii\db\mysql\QueryBuilder->init()
  #6 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/base/BaseObject.php(109): craft\db\mysql\QueryBuilder->init()
  #7 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/QueryBuilder.php(116): yii\base\BaseObject->__construct(Array)
  #8 /Users/username_0/dev/site.no/vendor/craftcms/cms/src/db/mysql/Schema.php(71): yii\db\QueryBuilder->__construct(Object(craft\db\Connection), Array)
  #9 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/Schema.php(249): craft\db\mysql\Schema->createQueryBuilder()
  #10 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/Connection.php(836): yii\db\Schema->getQueryBuilder()
  #11 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/db/Command.php(580): yii\db\Connection->getQueryBuilder()
  #12 /Users/username_0/dev/site.no/vendor/craftcms/cms/src/db/Command.php(142): yii\db\Command->update('{{%queue}}', Array, '[[timeUpdated]]...', Array)
  #13 /Users/username_0/dev/site.no/vendor/craftcms/cms/src/queue/Queue.php(507): craft\db\Command->update('{{%queue}}', Array, '[[timeUpdated]]...', Array, false)
  #14 /Users/username_0/dev/site.no/vendor/craftcms/cms/src/queue/Queue.php(449): craft\queue\Queue->_moveExpired()
  #15 /Users/username_0/dev/site.no/vendor/craftcms/cms/src/queue/Queue.php(95): craft\queue\Queue->reserve()
  #16 /Users/username_0/dev/site.no/vendor/craftcms/cms/src/queue/Command.php(82): craft\queue\Queue->run()
  #17 [internal function]: craft\queue\Command->actionRun()
  #18 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/base/InlineAction.php(57): call_user_func_array(Array, Array)
  #19 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\InlineAction->runWithParams(Array)
  #20 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/console/Controller.php(148): yii\base\Controller->runAction('run', Array)
  #21 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/base/Module.php(528): yii\console\Controller->runAction('run', Array)
  #22 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/console/Application.php(180): yii\base\Module->runAction('queue/run', Array)
  #23 /Users/username_0/dev/site.no/vendor/craftcms/cms/src/console/Application.php(93): yii\console\Application->runAction('queue/run', Array)
  #24 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/console/Application.php(147): craft\console\Application->runAction('queue/run', Array)
  #25 /Users/username_0/dev/site.no/vendor/yiisoft/yii2/base/Application.php(386): yii\console\Application->handleRequest(Object(craft\console\Request))
  #26 /Users/username_0/dev/site.no/craft(22): yii\base\Application->run()
  #27 {main}
  
  ```
  
  Ideas?
  
  **Tags:** craft3, error-message, console
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2019-03-13. Score: 2 | Accepted answer
  
  You might not have MAMP's PHP set as your CLI PHP. [Have a look at this guide](https://craftcms.com/guides/mamp-with-composer-and-mysql-on-the-command-line) and see if it gets you further
  
  
  ---
  
  ### Answer by username_2 on 2020-03-09. Score: 3
  
  I was able to fix this on my local MAMP installation by following the instructions for making MAMP play nicely with Craft in [this guide](https://craftcms.com/guides/mamp-with-composer-and-mysql-on-the-command-line), then executing the command `chmod a+x craft` from [this tutorial](https://nystudio107.com/blog/exploring-the-craft-cms-3-console-command-line-interface-cli).
  
  
  ---
  
  ### Answer by username_3 on 2019-03-13. Score: 1
  
  Try with `php craft ..` instead of `./craft ...`
  
  
  ---
  
  