1

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?

  • 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. – Sandwich Sep 2 at 12:26
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 article for details.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.