I fixed the issue.
I replaced the composer.json file (D8 version) with the one downloaded from github for recommended-project (version 9.5.9). I didn't change anything except to add the lines for modules installed my site. Then I re-ran composer install. This time, when I re-ran drush updb, it worked.
Thank you, almador, for your suggestions. It was the re-install idea that made me start from scratch there too.
I followed the instructions you gave me, did a full composer install that was completed without a glitch. Still drush fails to work when running "drush updb" but the error now has changed to something else. Hopefully it will give a better clue:
[preflight] Config paths: /drupal-project-root/vendor/drush/drush/drush.yml
[preflight] Alias paths: /drupal-project-root/web/drush/sites,/drupal-project-root/drush/sites
[preflight] Commandfile search paths: /drupal-project-root/vendor/drush/drush/src
[info] Starting bootstrap to full [0.24 sec, 8.11 MB]
In BootstrapHook.php line 36:
[Exception]
Bootstrap failed. Run your command with -vvv for more information.
Exception trace:
at /drupal-project-root/vendor/drush/drush/src/Boot/BootstrapHook.php:36
Drush\Boot\BootstrapHook->initialize() at /drupal-project-root/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:44
Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->doInitializeHook() at /drupal-project-root/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:36
Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->callInitializeHook() at /drupal-project-root/vendor/consolidation/annotated-command/src/Hooks/Dispatchers/InitializeHookDispatcher.php:29
Consolidation\AnnotatedCommand\Hooks\Dispatchers\InitializeHookDispatcher->initialize() at /drupal-project-root/vendor/consolidation/annotated-command/src/CommandProcessor.php:145
Consolidation\AnnotatedCommand\CommandProcessor->initializeHook() at /drupal-project-root/vendor/consolidation/annotated-command/src/AnnotatedCommand.php:375
Consolidation\AnnotatedCommand\AnnotatedCommand->initialize() at /drupal-project-root/vendor/symfony/console/Command/Command.php:221
Symfony\Component\Console\Command\Command->run() at /drupal-project-root/vendor/symfony/console/Application.php:1039
Symfony\Component\Console\Application->doRunCommand() at /drupal-project-root/vendor/symfony/console/Application.php:275
Symfony\Component\Console\Application->doRun() at /drupal-project-root/vendor/symfony/console/Application.php:149
Symfony\Component\Console\Application->run() at /drupal-project-root/vendor/drush/drush/src/Runtime/Runtime.php:124
Drush\Runtime\Runtime->doRun() at /drupal-project-root/vendor/drush/drush/src/Runtime/Runtime.php:51
Drush\Runtime\Runtime->run() at /drupal-project-root/vendor/drush/drush/drush.php:77
require() at /drupal-project-root/vendor/drush/drush/drush:4
include() at /drupal-project-root/vendor/bin/drush:120
This is the database definition in settings.php:
$databases['default']['default'] = array (
'database' => 'db_name',
'username' => 'db_user',
'password' => 'db_password',
'host' => 'localhost',
'port' => '3306',
'driver' => 'mysql',
'prefix' => '',
'collation' => 'utf8mb4_general_ci',
);
When I run "drush updb":
Error: Class "Drupal\mysql\Driver\Database\mysql\Connection" not found in Drupal\Core\Database\Database::openConnection() (line 463 of /drupal-project-dir/vendor/drupal/core/lib/Drupal/Core/Database/Database.php).
[warning] Drush command terminated abnormally.
With -vvv, this is the output:
Box Requirements Checker
========================
> Using PHP 8.1.18
> PHP is using the following php.ini file:
/opt/cpanel/ea-php81/root/etc/php.ini
> Checking Box requirements:
✔ The package "composer/xdebug-handler" requires the version "^5.3.2 || ^7.0 || ^8.0" or greater.
✔ The package "laravel-zero/phar-updater" requires the version "^7.3|^8.0" or greater.
✔ The package "psr/log" requires the version ">=5.3.0" or greater.
✔ The package "webmozart/assert" requires the version "^7.2 || ^8.0" or greater.
✔ The package "webmozart/path-util" requires the version ">=5.3.3" or greater.
✔ The package "webflo/drupal-finder" requires the extension "json".
✔ The package "webmozart/assert" requires the extension "ctype".
[OK] Your system is ready to run the application.
[preflight] Config paths: /drupal-project-dir/vendor/drush/drush/drush.yml
[preflight] Alias paths: /drupal-project-dir/web/drush/sites,/drupal-project-dir/drush/sites
[preflight] Commandfile search paths: /drupal-project-dir/vendor/drush/drush/src
[info] Starting bootstrap to full [0.31 sec, 9.5 MB]
[info] Drush bootstrap phase 5 [0.31 sec, 9.5 MB]
[info] Try to validate bootstrap phase 5 [0.31 sec, 9.5 MB]
[info] Try to validate bootstrap phase 5 [0.31 sec, 9.5 MB]
[info] Try to bootstrap at phase 5 [0.31 sec, 9.5 MB]
[info] Drush bootstrap phase: bootstrapDrupalRoot() [0.31 sec, 9.5 MB]
[info] Change working directory to /drupal-project-dir/web [0.31 sec, 9.5 MB]
[info] Initialized Drupal 9.5.9 root directory at /drupal-project-dir/web [0.31 sec, 9.5 MB]
[info] Try to validate bootstrap phase 5 [0.31 sec, 9.5 MB]
[info] Try to bootstrap at phase 5 [0.31 sec, 9.51 MB]
[info] Drush bootstrap phase: bootstrapDrupalSite() [0.31 sec, 9.51 MB]
[debug] Could not find a Drush config file at sites/default/drush.yml. [0.32 sec, 9.68 MB]
[info] Initialized Drupal site default at sites/default [0.32 sec, 9.68 MB]
[info] Try to validate bootstrap phase 5 [0.32 sec, 9.68 MB]
[info] Try to bootstrap at phase 5 [0.32 sec, 9.68 MB]
[info] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.32 sec, 9.68 MB]
[debug] Add service modifier [0.33 sec, 9.97 MB]
[info] Try to validate bootstrap phase 5 [0.33 sec, 9.97 MB]
Error: Class "Drupal\mysql\Driver\Database\mysql\Connection" not found in Drupal\Core\Database\Database::openConnection() (line 463 of /drupal-project-dir/vendor/drupal/core/lib/Drupal/Core/Database/Database.php).
[warning] Drush command terminated abnormally. [0.35 sec, 9.92 MB]
Is this what you meant?
Almador, when you say the output of CLI, what command do you mean?
Yes, I have access to the database but I'm unable to follow the instructions you provided as there's nothing to delete... mysql is NOT listed inside the blob, in either version (8.9.20 or 9.5.9) of the site database.
Hi almador, thank you for your quick response.
That seems to be the problem, mysql is not listed in the key_values database table, and I guess it should be. I couldn't check any other way as drush doesn't work at all.
Can mysql be enabled without drush and without access to the admin UI?
I have encountered exactly the same error today when upgrading from 8.9.20 to 9.5.9. All packages were successfully updated by composer. I updated settings.php from the new default.settings.php, and when I ran "drush updb", it failed. I updated drush, thinking it could be the reason, but the error persisted.
We are on My SQL 5.7.23-23 and PHP 8.1.18 (updated before running composer to update core-recommended).
This is the full drush -vvv error:
[preflight] Config paths: /drupal-root-dir/vendor/drush/drush/drush.yml
[preflight] Alias paths: /drupal-root-dir/web/drush/sites,/drupal-root-dir/drush/sites
[preflight] Commandfile search paths: /drupal-root-dir/vendor/drush/drush/src
[info] Starting bootstrap to full [0.28 sec, 8.1 MB]
[info] Drush bootstrap phase 5 [0.28 sec, 8.16 MB]
[info] Try to validate bootstrap phase 5 [0.28 sec, 8.16 MB]
[info] Try to validate bootstrap phase 5 [0.28 sec, 8.16 MB]
[info] Try to bootstrap at phase 5 [0.28 sec, 8.16 MB]
[info] Drush bootstrap phase: bootstrapDrupalRoot() [0.28 sec, 8.16 MB]
[info] Change working directory to /drupal-root-dir/web [0.28 sec, 8.16 MB]
[info] Initialized Drupal 9.5.9 root directory at /drupal-root-dir/web [0.28 sec, 8.16 MB]
[info] Try to validate bootstrap phase 5 [0.28 sec, 8.16 MB]
[info] Try to bootstrap at phase 5 [0.28 sec, 8.17 MB]
[info] Drush bootstrap phase: bootstrapDrupalSite() [0.28 sec, 8.17 MB]
[debug] Could not find a Drush config file at sites/default/drush.yml. [0.28 sec, 8.34 MB]
[info] Initialized Drupal site default at sites/default [0.28 sec, 8.34 MB]
[info] Try to validate bootstrap phase 5 [0.28 sec, 8.34 MB]
[info] Try to bootstrap at phase 5 [0.28 sec, 8.34 MB]
[info] Drush bootstrap phase: bootstrapDrupalConfiguration() [0.28 sec, 8.34 MB]
[debug] Add service modifier [0.29 sec, 8.57 MB]
[info] Try to validate bootstrap phase 5 [0.29 sec, 8.57 MB]
Error: Class "Drupal\mysql\Driver\Database\mysql\Connection" not found in Drupal\Core\Database\Database::openConnection() (line 463 of /drupal-root-dir/vendor/drupal/core/lib/Drupal/Core/Database/Database.php).
[warning] Drush command terminated abnormally. [0.31 sec, 8.9 MB]
I have tried commenting and uncommenting the 'namespace' entry in settings.php as suggested above but it doesn't make any difference.
Thank you, Alaa!