2

We have distributed cloud server architecture - storage, database and webserver. We have installed drush 8 on storage server, as there are project files. We do not have direct ssh to the database or webserver.

When I try to run e.g. drush cc all on this storage server, response is error: PDOException: could not find driver.

I suppose that problem is, that database server is remote (database is not on storage server), so drush cannot find SQL driver. Settings.php is configured correctly, site is running, only drush has problems.

I read more about drush aliases, or syncing, but I do not think, that this is the solution for my problem. Do you know how to solve this problem and how to use drush on this type of server infrastructure?

Thanks for your help.

3

If it is possible for your Drupal site to access the database, then it is possible for Drush to access the database. In fact, Drush uses Drupal code to bootstrap, so it should really work the same.

What appears to be the issue here is that you do not have all of the same extensions (esp. the PDO extension) available in php-cli as you do in php-cgi or php-fpm or whatever you are using for your web server. Another issue that can sometimes come up is permissions, if you are running Drush under a different user than the web server.

Finally, it is also worth noting that not all Drush commands go through the Drupal bootstrap to access the database. The sql-* commands use the database commandline tools (mysql, psql, etc.), so these Drush commands may not work (e.g. if the database commandline tools are not installed).

  • Thanks for your answer. I have checked php-cli included extensions and are the same as in php-fpm. Also php.ini is nearly the same in both of them. I have tested it this way - installed drush 5 from apt repository (debian). Went to drupal 7 folder and executed drush cc all - it worked. But on drush 8 installation (installed by composer), command drush cc all returned error - <h1>Additional uncaught exception thrown while handling exception.</h1><h2>Original</h2><p>PDOException: could not find driver in drupal_is_denied(). Tested on Drupal7 and Drupal8 sites, result is the same. – Juraj Nemec Dec 15 '16 at 9:50
  • Try to verify that drush5 and drush8 are seeing the same php binary. I hit this error when I compiled php7 in a dev environment while testing some other tools, and drush picked up on that binary. So the web server was happily using the correct php, and drush was failing hard with that same "could not find driver" exception. – phils Feb 8 '18 at 1:39

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.