Drupal Error Class Drupal mysql Driver not found

drupal-mysql-driver-not-found

As a Drupal developer or site administrator, you might encounter this error message when migrating a Drupal site to a new server.

Got error 'PHP message: Error: Class "Drupal\\mysql\\Driver\\Database\\mysql\\Connection" not found in public_html/core/lib/Drupal/Core/Database/Database.php

So, how can you resolve this? In this blog post, we will explore how to fix it.

Step #1

Change file and folder permission to make settings.php file writable. Apply following permission.

  • /sites/default 755
  • /sites/default/settings.php 644

Step #2

Open settings.php in text editor.

  • Check and make sure these are correct: database name, database username, database password.
  • Check namespace line. It should be like this:
  • 'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql',
    
  • Check autoload line. It should be like this:
  • 'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/',
    

Save the file after editing.

Step #3

Check your website, it should be fixed now. You should now revert the file and folder permission to default.

  • /sites/default 555
  • /sites/default/settings.php 444
Category: