0

I just updated my macos' php version using homebrew. This worked, the php version I'm currently running is 8.0.2

But doing this my Drush stopped working. When running drush cr I get the following error:

In Connection.php line 189:
SQLSTATE[HY000] [2002] No such file or directory 

I tried several suggestions mentioned here: I've got `PDOException: SQLSTATE[HY000] [2002] No such file or directory` when using drush

The highest voted answer:

sudo mkdir /var/mysql
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /var/mysql/mysql.sock

Gives me the following feedback:

mkdir: /var/mysql: File exists
ln: /var/mysql/mysql.sock: File exists

When I then run mysql_config --socket I get /Applications/MAMP/tmp/mysql/mysql.sock as return.

I also tried changing the .zprofile on my computer. I added:

export PATH=/Applications/MAMP/bin/php/php8.0.2/bin:$PATH

and

export DRUSH_PHP="/Applications/MAMP/bin/php/php8.0.2/bin/php"

But, as you might see, I don't really know what I'm doing and why. Can someone help me get Drush working again? I'm working on Drupal 9 websites using Drush 11 (drush -v is working).

6
  • "drush stopped working"-- what doesn't work? drush can't be found? drush can't connect to your site? which commands work and which don't? Jul 11, 2022 at 11:07
  • Sorry, I thought I mentioned that...I updated my question
    – Joost
    Jul 11, 2022 at 11:09
  • Also, if you don't understand what you're doing, you should carefully keep notes of any changes that you make to your system, because you are likely to change things that don't need to be changed, causing even more problems down the line. If a change doesn't fix the problem, it should be undone immediately. Jul 11, 2022 at 11:09
  • Are you certain MySQL is running?
    – mona lisa
    Jul 11, 2022 at 11:15
  • 1
    I was on MAMP for years. Switched to DDEV. Never looked back.
    – leymannx
    Jul 11, 2022 at 12:00

1 Answer 1

5

Use 127.0.0.1 instead of localhost in the database connection configuration.

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.