I have a MAMP with PHP 7.1.8 up and running. I downloaded my production Magento 2.2 based website and also imported the MySQL database into my localhost phpMyAdmin.Then I changed the URL in the core_config_data table to reflect the localhost URL to get to the site.

However now when I go to the site in the browser I get this error An error has happened during an application run. See exception log for details.

when I look at the exception.log I see it says

main.CRITICAL: PDOException: SQLSTATE[HY000] [2002] No such file or directory in /Applications/MAMP/htdocs/devkisseurope/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:128

I googled around and see mention that it may mean that the PHP version. being used is not the same version that MAMP uses. However, I edited the ~/.bash_profile as well as the ~/.profile files and rebooted. now when I run

which PHP

I see the below which is the correct bath the php I am using


So I am not sure what i am missing to get my Magento2 running locally for development?

I have been able to install a Magento 2.2 from scratch with no issues. I am just not able to get a copy of an already developed production magento 2.2 site to run locally on my mamp server so I can further develop it.

  • Possible duplicate of Install Magento 2 with MAMP
    – MagenX
    Jan 2, 2018 at 22:14
  • this is not a duplicate of that question for many reasons: - The post is from 2014 and the poster is trying to install "Magento Beta" - I am able to install a magento from scratch in another MAMP directory. However what I am trying to do is get a copy of a production magento 2.2 site to work locally for development purposes. So I am not going through Composer to install magento.
    – Jayreis
    Jan 2, 2018 at 22:29
  • I also indicated in my above post that I am using the same php version in MAMP as I am in the mac as indicated by what it says when I run Which PHP
    – Jayreis
    Jan 2, 2018 at 22:31
  • Error is not about php but mysql. Your mysql server is either not starting or your configuration is incorrect.
    – Zefiryn
    Jan 2, 2018 at 22:43

1 Answer 1

  1. Check the PHP version your webserver you are using. Do it by creating a phpinfo.php page with the below contents.

<?php phpinfo(); ?>

  1. Run the php -i | grep 'php.ini' on your SSH / CLI terminal. Check the PHP settings from the file found.

If the settings/version present in step 1 & step 2 to differ then apply the same PHP settings present on your webserver to your CLI.

  1. Say, the PHP version you want to point to is 5.6.32, then run the below command on your CLI.

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

  1. Start off with a new terminal. Also, check if the changes are reflected by executing the command again on CLI php -i | grep 'php.ini'

If you need more details, please find here

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.