Hello,
I have successfully installed magento on a local MAMP server. It is not possible to reindex the indexes. I have tried to the followed procedures:
1. for setting up the cron jobs I tried:
http://claudiucreanga.github.io/magento/magento2-setup-with-mamp-including-crons.html
2. when I am in my magento root directory and I type in the terminal: php bin/magento indexer:reindex
I just get the error messages:
[Zend_Db_Adapter_Exception]
SQLSTATE[HY000] [2002] No such file or directory
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
I tried to resolve this problem using this:
https://magento.stackexchange.com/questions/51948/sqlstatehy000-2002-no-such-file-or-directory-error
but:
I don't know where I can change the database hostname.
when I open the phpinfo.php file in the root of the magento installation I find:
Configuration File (php.ini) Path | /Applications/MAMP/bin/php/php7.0.22/conf |
Loaded Configuration File | /Library/Application Support/appsolute/MAMP PRO/conf/php.ini |
should these two values be equal? (I don't know how to find out which php.ini file PHP command-line interface (CLI) is using)
and I cannot find the app/etc/local.xml file.
please help me, I am desperate.
best regards,
David
to check what version php cli is using you type in terminal : php -v
if cli is using another version of php then the one installed in mamp you can specify cli to use the version in mamp. The command should look something like this : /Applications/MAMP/bin/php/php7.0.20/bin/php magento indexer:reindex
Hello, thanks for the reply.
I just entered php -v, output:
PHP 7.0.22 (cli) (built: Aug 17 2017 11:29:35) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
7.0.22 is the version which is stated in the phpinfo.php page as well, so this should be okay.
how do I set up the cron jobs properly? this is what I entered in the crontab:
*/1 * * * * /Applications/MAMP/bin/php/php7.0.22/conf -c /Library/Application Support/appsolute/MAMP PRO/conf/php.ini /Applications/MAMP/htdocs/magento/bin/magento cron:run >> /Applications/MAMP/htdocs/magento/var/log/setup.cron.log&
*/1 * * * * /Applications/MAMP/bin/php/php7.0.22/conf -c /Library/Application Support/appsolute/MAMP PRO/conf/php.ini /Applications/MAMP/htdocs/magento/update/cron.php >> /Applications/MAMP/htdocs/magento/var/log/setup.cron.log&
*/1 * * * * /Applications/MAMP/bin/php/php7.0.22/conf -c /Library/Application Support/appsolute/MAMP PRO/conf/php.ini /Applications/MAMP/htdocs/magento/bin/magento setup:cron:run >> /Applications/MAMP/htdocs/magento/var/log/setup.cron.log&
when I am entering in the terminal
/Applications/MAMP/bin/php/php7.0.22/bin/php magento indexer:reindex
it responds: Could not open input file: magento
best regards
if your're in the root folder of your magento project you need to add "bin" to the command. either of these commands should work :
/Applications/MAMP/bin/php/php7.0.20/bin/php ./bin/magento indexer:reindex
or
/Applications/MAMP/bin/php/php7.0.20/bin/php bin/magento indexer:reindex
Is there a reason why I should use 7.0.20 instead of 7.0.22(which is my CLI version and the version which is stated on the phpinfo.php page)? Independent which one I try I always get the same response:
Davids-MacBook-Pro:bin david$ /Applications/MAMP/bin/php/php7.0.22/bin/php ./bin/magento indexer:reindex
Could not open input file: ./bin/magento
You have mail in /var/mail/david
Davids-MacBook-Pro:bin david$ /Applications/MAMP/bin/php/php7.0.22/bin/php bin/magento indexer:reindex
Could not open input file: bin/magento
just out of curiosity I went to the root directory of my magenta installation and entered "php bin/magento indexer:reindex". Suddenly it worked. I don't know why it works now... I tried this multiple times and always got the same response:
Zend_Db_Adapter_Exception]
SQLSTATE[HY000] [2002] No such file or directory
[PDOException]
SQLSTATE[HY000] [2002] No such file or directory
indexer:reindex [index1] ... [indexN]
I really dont know why it works now and would love to know what is different now...
thanks for your help.
best regards,
David
I found a way to resolve this issue is:
get error: SQLSTATE[HY000] [2002] No such file or directory
solution: create symlink from mamp mysql.sock to /tmp/mysql.sock
ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock
The cause of my case is Mamp install mysql and socket in other directory and Magento 2 looking mysql.sock in default place. So we just need to link the default place to Mamp place. This will resolve this issue.
I noted some other issues I got when install mamp here:
https://mrvts.wordpress.com/2019/08/25/mac-pro-install-and-use-mamp-pro-for-magento/
This resolve my problem!. Thanks.