Pascal Pivaty
Pascal Pivaty

Reputation: 97

Problems using drupal / console

I installed Drupal Console Launcher as described in the documentation :

curl https://drupalconsole.com/installer -L -o drupal.phar
mv drupal.phar /usr/local/bin/drupal
chmod +x /usr/local/bin/drupal

It works fine and the 'drupal' command works.

After I installed the console in the site folder :

composer.phar require drupal/console:~1.0 \
--prefer-dist \
--optimize-autoloader

When I run the 'drupal list' command in the site folder I have a message : SQLSTATE[HY000] [2002] No such file or directory

So I edited the 'host' in the 'settings.php' file replacing 'localhost' for '127.0.0.1'

In this case, I have a SQLSTATE [HY000] [2002] Connection refused error and the site no longer works!

I also tried installing drupal 8 with Composer to have the console. There I have an error SQLSTATE [HY000] [2002] Connection refused

It's been almost a week now that I try in all directions without success!

I'm on OSX with a MAMP server.

Would anyone have an idea ?

Upvotes: 4

Views: 702

Answers (1)

Nicolas Bouteille
Nicolas Bouteille

Reputation: 11

Here are all the links that helped me solve the exact same problem:

Working with Drush on MAMP https://www.drupal.org/node/1651282 https://drupal.stackexchange.com/a/180924

https://docs.drupalconsole.com/en/drupal_console_faq/installation-problems.html

The problem is that I am hosting the site and database with MAMP on mac OS, but Drupal Console and Drush use the terminal, thus the system's PHP version and MySQL socket. Not the one from MAMP. So any article explaning how to make Drupal Console or Drush work with MAMP can be useful.

In my case, the only thing missing if I'm not mistaken was a symbolik link on MAMP's mysql socket

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

But the articles above also show us how to use MAMP's default PHP version from the terminal and other things good to know!

Upvotes: 1

Related Questions