I followed exactly this setup: https://github.com/magento/magento2-samples/tree/master/sample-module-minimal and added the registration.php file, and run php bin/magento module:enable Company_Basic, but after I run php bin/magento setup:upgrade I get the following error:

  SQLSTATE[HY000] [2002] No such file or directory

If I change from localhost to in env.php I get:

  SQLSTATE[HY000] [2002] Connection refused

Now the website throws this error:

Please upgrade your database: Run "bin/magento setup:upgrade" from the Magento root directory. 
The following modules are outdated:

I'm using mamp. I installed magento2 ok, but now it appears that mysql is connecting. Any ideas? Thanks!

Update: If I run /Applications/MAMP/Library/bin/mysqld --version I get

/Applications/MAMP/Library/bin/mysqld  Ver 5.6.25 for osx10.6 on x86_64 (MySQL Community Server (GPL))

1 Answer 1


The issue was that php and mamp mysql did not communicate. I was using mac php and mac mysql. But my database is in mamp mysql.

Inserting this in my bash profile:

export PATH=/Applications/MAMP/Library/bin/:/Applications/MAMP/bin/php5/bin/:/opt/local/bin:/opt/local/sbin:$PATH

export PATH=/Applications/MAMP/bin/php/php5.6.10/bin:$PATH

made sure that in command line I'm using mamp php and mamp mysql.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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