Answers.Body: <p>So this is a MAMP/local dev issue -- run via the CLI, Craft can't connect to the db. Probably it's looking for the wrong <code>mysql</code>.</p>
  
  <p>Check out the <a href="https://craftcms.com/guides/mamp-with-composer-and-mysql-on-the-command-line" rel="nofollow noreferrer">MAMP with Composer and MySQL on the Command Line</a> article for details.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-11T14:40:44.070Z
Answers.Text: Thanks. I followed the instructions through to and including https://craftcms.com/guides/mamp-with-composer-and-mysql-on-the-command-line#using-mAMPs-mySQL-server-in-terminal, but no joy. I must be doing something wrong.
Answers.UserDisplayName: Jonathan Schofield
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-11T16:16:46.870Z
Answers.Text: I don't use MAMP, sorry
Answers.UserDisplayName: andrew.welch
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-11T17:10:26.467Z
Answers.Text: This is most likely the correct answer - here are a couple more links for you https://www.youtube.com/watch?v=qRA2k6FICsY is a video that explains the issue in depth, and here's a related Craft module: https://packagist.org/packages/samhernandez/craft-db-paths
Answers.UserDisplayName: Sam Hernandez
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-14T16:39:18.533Z
Answers.Text: Thanks Sam. That is super helpful in lots of ways. Very well explained :)
Answers.UserDisplayName: Jonathan Schofield
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-04-11T14:02:32.537Z
Answers.LastActivityDate: 2019-04-11T14:02:32.537Z
Answers.UserDisplayName: andrew.welch
Body: <p>My command line skills are limited but I’m trying to be better. I’ve been using <code>composer</code> successfully for a while to initiate Craft installs, but then subsequently using the Craft web GUI to install plugins.</p>
  
  <p>Today I thought I’d try and use the command line on a fresh local install, which has DB connection details stored in <code>.env</code> as is usual. The host is configured through MAMP Pro on Mac OS Mojave.</p>
  
  <p>I’ve run <code>composer update</code> on my install and it reported there was nothing to update.</p>
  
  <p>I then used the web GUI to install <code>craftcms/contact-form</code> and all went fine, so there is no doubt that my local DB credentials are correct.</p>
  
  <p>Then, in the command line I invoked:</p>
  
  <pre><code>composer require craftcms/contact-form-honeypot
  </code></pre>
  
  <p>…which ran fine. And then:</p>
  
  <pre><code>./craft install/plugin contact-form-honeypot
  </code></pre>
  
  <p>…and got: </p>
  
  <blockquote>
    <p>"failed to install contact-form-honeypot: Craft CMS can’t connect to the database with the credentials in config/db.php."</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2020-09-02T12:26:33.340Z
Comments.Text: Incidentally—and this is probably not the issue you were encountering—the handle you pass to `./craft` often differs from the handle passed to `composer`.
Comments.UserDisplayName: Sandwich
Tags: <plugins><composer>
Title: Getting my head round installing plugins from the command line
ThreadText: # Getting my head round installing plugins from the command line
  
  (Asked by: username_0 on 2019-04-11)
  
  My command line skills are limited but I’m trying to be better. I’ve been using `composer` successfully for a while to initiate Craft installs, but then subsequently using the Craft web GUI to install plugins.
  
  Today I thought I’d try and use the command line on a fresh local install, which has DB connection details stored in `.env` as is usual. The host is configured through MAMP Pro on Mac OS Mojave.
  
  I’ve run `composer update` on my install and it reported there was nothing to update.
  
  I then used the web GUI to install `craftcms/contact-form` and all went fine, so there is no doubt that my local DB credentials are correct.
  
  Then, in the command line I invoked:
  
  ```
  composer require craftcms/contact-form-honeypot
  
  ```
  
  …which ran fine. And then:
  
  ```
  ./craft install/plugin contact-form-honeypot
  
  ```
  
  …and got:
  
  > "failed to install contact-form-honeypot: Craft CMS can’t connect to the database with the credentials in config/db.php."
  
  What am I doing wrong?
  
  **Tags:** plugins, composer
  
  > **Comments:**
  > **username_1**: Incidentally—and this is probably not the issue you were encountering—the handle you pass to `./craft` often differs from the handle passed to `composer`.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2019-04-11. Score: 2
  
  So this is a MAMP/local dev issue -- run via the CLI, Craft can't connect to the db. Probably it's looking for the wrong `mysql`.
  
  Check out the [MAMP with Composer and MySQL on the Command Line](https://craftcms.com/guides/mamp-with-composer-and-mysql-on-the-command-line) article for details.
  
  > **Comments:**
  > **username_0**: Thanks. I followed the instructions through to and including https://craftcms.com/guides/mamp-with-composer-and-mysql-on-the-command-line#using-mAMPs-mySQL-server-in-terminal, but no joy. I must be doing something wrong.  
  > **username_2**: I don't use MAMP, sorry  
  > **username_3**: This is most likely the correct answer - here are a couple more links for you https://www.youtube.com/watch?v=qRA2k6FICsY is a video that explains the issue in depth, and here's a related Craft module: https://packagist.org/packages/username_3/craft-db-paths  
  > **username_0**: Thanks Sam. That is super helpful in lots of ways. Very well explained :)  
  
  ---
  
  