0

I have an old Drupal 7 project and I need to set it up on my localhost. I have Ubuntu 16.04, Apache 2, php 7.0, and MySQL 5.7 installed. Everything is working fine for other PHP scripts, But when I tried to install Drupal 7 project, I got this error.

Your web server does not appear to support any common PDO database extensions. Check with your hosting provider to see if they support PDO (PHP Data Objects) and offer any databases that Drupal supports.

I could not figure it out why Drupal doesn't detect PDO. How can I fix this issue?

4
  • 2
    It's not sufficient to have the PDO support enabled; it requires to also have PDO drivers installed. If other scripts aren't using PDO, they would not throw the same error reported by Drupal. – apaderno Nov 14 '20 at 14:11
  • @kiamlaluno yeah! but i have tested it with a script which is using PDO. for that it works fine – Iqbal Nov 14 '20 at 14:21
  • moreover, it detects postgreSQL but detecting mysql. – Iqbal Nov 14 '20 at 14:40
  • Double check your php installation for PDO support. E.g., a simple page that just has phpinfo(); – beltouche Nov 14 '20 at 22:36
1

The error could be thrown for three different reasons.

  • Some of the Drupal core files in the includes/database directory are missing
  • There isn't any extension implementing the necessary PDO drivers
  • The extension implementing the necessary PDO driver isn't enabled in the php.ini file or other .ini files used from PHP

To check which database driver is available, Drupal first looks for its own files in the includes/database directory, initializes an instance of a class that extends DatabaseTasks (for example DatabaseTasks_mysql for MySQL) and calls its installable() method.

public function installable() {
  return $this->hasPdoDriver() && empty($this->error);
}

protected function hasPdoDriver() {
  return in_array($this->pdoDriver, PDO::getAvailableDrivers());
}

If the method returns FALSE, the PDO driver is considered not available. (See drupal_get_database_types() for details.)

Notice that, if the PDO extension (not a PDO driver) isn't available, the error shown from Drupal is the following one.

'Your web server does not appear to support PDO (PHP Data Objects). Ask your hosting provider if they support the native PDO extension.

In that case, Drupal would also show the following message, followed by a list of one or more missing PHP extensions.

Drupal requires you to enable the PHP extensions in the following list (see the system requirements page for more information)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.