I am trying to update Drupal from version 8.7.5 to 8.7.7. I installed Drupal using composer and had a really old version of Drush that I had installed from apt-get. I uninstalled the old version and installed an up to date version. However, I still cannot update the database, I think because it doesn't connect. Drupal itself can connect to the database (obviously because the site has been up and running for months and I have not changed anything other than to try to update things) but for some reason Drush cannot. Weirdly, when I do drush status, it shows a Drupal version of 8.7.3, which is not correct. I have tried doing drush cache:clear it clears everything but does not change any of the issues. When I do drush rebuild I get ' SQLSTATE[HY000] [1044] Access denied for user 'user'@'%' to database 'database'`. Any help in getting drush to connect to the database would be much appreciated. Thanks.

drush status

 Drupal version : 8.7.3                                             
 Site URI       : http://default                                    
 DB driver      : mysql                                             
 DB hostname    : localhost                                         
 DB port        : 3306                                              
 DB username    : joomla                                            
 DB name        : otherrealmdrupal                                  
 PHP binary     : /usr/bin/php7.3                                   
 PHP config     : /etc/php/7.3/cli/php.ini                          
 PHP OS         : Linux                                             
 Drush script   : /usr/bin/drush                                    
 Drush version  : 9.7.1                                             
 Drush temp     : /tmp                                              
 Drush configs  : /root/.drush/drush.yml                            
 Drupal root    : /var/www/html/drupal                              
 Site path      : sites/default    

drush updatedb

Drush Launcher Version: 0.6.0
ROOT: /var/www/html/drupal
DRUPAL ROOT: /var/www/html/drupal
COMPOSER ROOT: /var/www/html/drupal
VENDOR ROOT: /var/www/html/drupal/vendor
 [preflight] Config paths: /root/.drush/drush.yml,/var/www/html/drupal/vendor/drush/drush/drush.yml
 [preflight] Alias paths: /root/.drush/sites,/etc/drush/sites,/var/www/html/drupal/drush/sites,/var/www/html/drush/sites
 [preflight] Commandfile search paths: /var/www/html/drupal/vendor/drush/drush/src
 [bootstrap] Starting bootstrap to full [0.22 sec, 8.49 MB]
 [bootstrap] Drush bootstrap phase 5 [0.22 sec, 8.49 MB]
 [bootstrap] Try to validate bootstrap phase 5 [0.22 sec, 8.49 MB]
 [bootstrap] Try to validate bootstrap phase 5 [0.22 sec, 8.49 MB]
 [bootstrap] Try to bootstrap at phase 5 [0.22 sec, 8.49 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalRoot() [0.22 sec, 8.49 MB]
 [bootstrap] Change working directory to /var/www/html/drupal [0.22 sec, 8.49 MB]
 [bootstrap] Initialized Drupal 8.7.3 root directory at /var/www/html/drupal [0.23 sec, 8.62 MB]
 [bootstrap] Try to validate bootstrap phase 5 [0.23 sec, 8.62 MB]
 [bootstrap] Try to bootstrap at phase 5 [0.24 sec, 8.92 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalSite() [0.24 sec, 8.92 MB]
 [bootstrap] Initialized Drupal site default at sites/default [0.24 sec, 9.15 MB]
 [bootstrap] Try to validate bootstrap phase 5 [0.24 sec, 9.15 MB]
 [bootstrap] Try to bootstrap at phase 5 [0.24 sec, 9.15 MB]
 [bootstrap] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.24 sec, 9.15 MB]
 [debug] Add service modifier [0.25 sec, 9.38 MB]
 [bootstrap] Try to validate bootstrap phase 5 [0.25 sec, 9.38 MB]
 [bootstrap] Unable to connect to database. More information may be 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.26 sec, 9.63 MB]
 [bootstrap] Could not bootstrap at phase 5 [0.26 sec, 9.62 MB]

In BootstrapHook.php line 32:

  Bootstrap failed. Run your command with -vvv for more information.  

Exception trace:
  at /var/www/html/drupal/vendor/drush/drush/src/Boot/BootstrapHook.php:32
 Drush\Boot\BootstrapHook->initialize() at /var/www/html/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:34
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook() at /var/www/html/drupal/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:27
 Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize() at /var/www/html/drupal/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
 Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at /var/www/html/drupal/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:289
 Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at /var/www/html/drupal/vendor/symfony/console/Command/Command.php:221
 Symfony\Component\Console\Command\Command->run() at /var/www/html/drupal/vendor/symfony/console/Application.php:981
 Symfony\Component\Console\Application->doRunCommand() at /var/www/html/drupal/vendor/symfony/console/Application.php:254
 Symfony\Component\Console\Application->doRun() at /var/www/html/drupal/vendor/symfony/console/Application.php:147
 Symfony\Component\Console\Application->run() at /var/www/html/drupal/vendor/drush/drush/src/Runtime/Runtime.php:118
 Drush\Runtime\Runtime->doRun() at /var/www/html/drupal/vendor/drush/drush/src/Runtime/Runtime.php:49
 Drush\Runtime\Runtime->run() at /var/www/html/drupal/vendor/drush/drush/drush.php:72
 require() at /var/www/html/drupal/vendor/drush/drush/includes/preflight.inc:18
 drush_main() at phar:///usr/bin/drush/bin/drush.php:141
 require() at /usr/bin/drush:10

updatedb [--cache-clear [CACHE-CLEAR]] [--entity-updates] [--post-updates [POST-UPDATES]] [--no-cache-clear] [--no-post-updates] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-d|--debug] [-y|--yes] [--no] [--remote-host REMOTE-HOST] [--remote-user REMOTE-USER] [-r|--root ROOT] [-l|--uri URI] [--simulate] [--pipe] [-D|--define DEFINE] [--notify [NOTIFY]] [--druplicon] [--xh-link XH-LINK] [--] <command>
  • 1
    Drush is supposed to be installed as local dependency, not globally anymore. See docs.drush.org/en/master/install on the very top. Then it's cd web && ../vendor/drush/drush/drush status or you install Drush Launcher on your server then it's just cd web && drush status as usual. Please see if having a local Drush and calling it from the correct directory fixes your problem. Many thanks
    – leymannx
    Sep 30, 2019 at 9:02
  • Hey, did you find out the problem with this? I'm facing exactly the same problem.
    – zapico
    Jul 17, 2020 at 14:51

1 Answer 1


Finally figured out the problem.

Just change the host line in your settings.local.php:

'host' => '',

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.