- Status changed to Postponed: needs info
almost 2 years ago 3:42pm 17 January 2023 - Status changed to Fixed
almost 2 years ago 11:34pm 17 January 2023 Automatically closed - issue fixed for 2 weeks with no activity.
- Status changed to Fixed
over 1 year ago 9:07pm 14 May 2023 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.
- 🇬🇪Georgia almador
drupalsilm
Did you check in the modules list if the 'mysql' module is installed? 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?
- 🇬🇪Georgia almador
drupalsilm, could you please provide the output of CLI when you are trying to run drush?
Also, it seems that you have direct access to the database. You could try from here:
- - Manually edit the config table where name = 'core.extension' and remove the module from the data blob which is a serialized array.
- - Be aware to decrement the module array length as well (...s:6:"module";a:HERE;{...)
- - Truncate the cache_config table from phpmyadmin or using command-line.
https://drupal.stackexchange.com/questions/72927/manually-disable-a-module
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.
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?
- 🇬🇪Georgia almador
I suggest you've already tried removing:
'namespace' => 'Drupal\Driver\Database\mysql',
from settings.phpI can't remember how it was fixed in my situation, but you could try to:
- rename drupal 'web/core' folder to 'web/core2'
- rename 'vendor' folder to 'vendor2'
- rename 'composer.lock' to 'composer_old.lock'
- run 'composer install'
- run 'drush cr' and 'drush updb'Make sure you've created the code and database backup before doing this!
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:120This 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',
);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.
- 🇱🇹Lithuania vibrasphere
Happened same with Drupal 10.
Built the website on local Windows 10 and uploaded it to Ubuntu.
For some reason settings.php formatting was like this:
'autoload' => 'core/modules/mysql\\src\\Driver\\Database\\mysql\\',
And if you replace it with this, the issue is solved:
'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
- 🇦🇹Austria dawitti
I faced the same issue after migrating a site to a new server and simply copying all files.
As @almador said in #19, deleting vendor, composer.lock and the web/core directory, and the restoring it via composer install fixed the issue for me.
Make a backup before deleting things.