0

I have an error when i try to update my db or install a module with drush.

[info] Try to validate bootstrap phase 5 [0.11 sec, 10.08 MB] [info] Unable to connect to database with message: SQLSTATE[HY000] [2002] No such file or directory. More debug information is available by running drush status. This may occur when Drush is trying to bootstrap a site that has not been installed or does not have a configured database. In this case you can select another site with a working database setup by specifying the URI to use with the --uri parameter on the command line. See drush topic docs-aliases for details. [0.11 sec, 10.31 MB] [info] Could not bootstrap at phase 5 [0.11 sec, 10.29 MB]

this is my drush status. Drupal version : 9.5.4
Site URI : http://default
DB driver : mysql
DB hostname : localhost
DB port : 3306
DB username : root
DB name : DruCar
PHP binary : /opt/homebrew/Cellar/[email protected]/8.1.15/bin/php
PHP config : /opt/homebrew/etc/php/8.1/php.ini
PHP OS : Darwin
PHP version : 8.1.15
Drush script : /usr/local/bin/drush
Drush version : 11.5.1
Drush temp : /tmp
Drush configs : /Applications/XAMPP/xamppfiles/htdocs/DruCar/recommended-project/vendor/drush/drush/drush.yml Drupal root : /Applications/XAMPP/xamppfiles/htdocs/DruCar/recommended-project/web
Site path : sites/default

anyway, i cant install anything with drush en.

Thank you anticipate.

1
  • 2
    Get rid of XAMPP. Use DDEV. You don't need an UI, you need a tool that's optimised as a local Drupal/PHP development environment.
    – leymannx
    Mar 2, 2023 at 23:07

2 Answers 2

1

This is likely the well-known situation of using localhost for the database configuration, which is interpreted by some database extensions as an instruction to use a unix socket file, and then the unix socket file is not properly configured. The usual solution is to use 127.0.0.1, the IPv4 address, instead of localhost in the database configuration. See https://serverfault.com/questions/295285/mysql-cannot-connect-via-localhost-only-127-0-0-1

Core has this issue, https://www.drupal.org/project/drupal/issues/2610858, which is attempting to improve error messaging about it, which may or may not impact Drush. Drush has had this question asked many, many times.

1

agre with answer from @cilefen

this is my example for local project. try doing the same, bottom line - use 127.0.0.1 instead of localhost in file

settings.local.php

$databases['default']['default'] = array (
    'database' => 'yourproject_local',
    'username' => 'root',
    'password' => 'yourpassword',
    'prefix' => '',
    'host' => '127.0.0.1',
    'port' => '3306',
    'driver' => 'mysql',
);

$settings['trusted_host_patterns'] = array(
    '^subdomain\.test\.yourise\.local',
    '^yoursite\.dev\.local$',
    '^subdomain\.something\.yourhosting\.com$',
    '^example\.at$',
    '^www\.example\.at$',
);
2
  • If you agree with a given answer, wait you can up-vote answers and up-vote the existing answer. There is no need to add an answer just to repeat what already said, especially when the existing answer provides links that explain why it happens.
    – apaderno
    Mar 20, 2023 at 14:02
  • of course, i've just added example how I use my settings.local.php file so maybe someone will use this snippet one day. I would like sometimes to get answers like that in my own questions.
    – metalac
    Mar 20, 2023 at 14:07

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.