I tried installing Drush with both methods listed in the drush.org documentation. I think they might be conflicting with each other if that's possible.

When I run composer global require drush/drush all the components appear to install correctly. However when I change to a Drupal site (Using XAMPP, /opt/lampp/htdocs/sitefolder) and run drush status I get the following error:

PHP Fatal error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php on line 56 Drush command terminated abnormally due to an unrecoverable error.
[error] Error: Undefined class constant 'MYSQL_ATTR_SSL_CA' in phar:///usr/local/bin/drush/lib/Drush/Sql/Sqlmysql.php, line 56

I do have the following line in my ~/.bashrc:

export PATH="$HOME/.composer/vendor/bin:$PATH"

Unfortunately I don't know how to troubleshoot from here, as there doesn't seem to be an easy way to uninstall Drush via the main method (http://docs.drush.org/en/master/install/), which didn't seem to work for me. composer global remove drush/drush does appear to run successfully.

Thanks in advance.

  • Its funny, yesterday I published a similar thread and deleted it after one of the users told me its a bug.
    – user16289
    Jun 26, 2016 at 5:52
  • I reported it as bug in Drush github. Are you using WSL? Happened to me in WSL but not in Ubuntu.
    – user16289
    Jun 26, 2016 at 5:53

4 Answers 4


In my case, not all of the PHP packages made it though the Ubuntu upgrade to 16.04 (which now runs PHP 7 by default). I needed to add the missing one, and then Drush started working again:

sudo apt install php-mysql

Or for php5 users

sudo apt install php5-mysql 

on very recent Ubuntu/Debian distributions.

For PHP 7.1:

sudo apt install php7.1-mysql

For PHP 7.2:

sudo apt install php7.2-mysql

You can search for your version using this:

apt-cache search php-mysql
  • Thanks, this fixed it. Just running sudo apt install php-mysql automatically installs the newest version
    – Collins
    May 12, 2020 at 13:26

Went down a bit of a rabbit hole on this one, but I believe the issue was related to drush connecting to the proper version of mysql. It needs the XAMPP version, not my local linux version. Adding these two lines to ~/.bashrc helped:

export DRUSH_PHP=/opt/lampp/bin/php

export PATH=$PATH:/opt/lampp/bin

had the same problem on Fedora 25. i had upgraded to php 5.6.32 from 5,60,30 and neglected a switch in the compile of 32.

doing php -m showed that 5.6.32 neglected to have module "pdo_mysql". So i reverted back to 5.6.30 that has that module compiled in, until i can debug the 5.6.32 compile.

after this change Drush 8 worked just fine.


Make sure you have the most up-to-date extensions for your version of PHP. You can find a list of the basic items you should install in the comments on the PHP documentation site under the upgrade to 7.1.

They recommend running: sudo apt-get install php7.1 php7.1-cli php7.1-common libapache2-mod-php7.1 php7.1-mysql php7.1-fpm php7.1-curl php7.1-gd php7.1-bz2 php7.1-mcrypt php7.1-json php7.1-tidy php7.1-mbstring php-redis php-memcached

If you don't, you will at very least run into issues with mbstring as this is a core dependency. This is also a potential solution for the all-too-common error "easyrdf/easyrdf 0.9.1 requires ext-mbstring * -> the requested PHP extension mbstring is missing from your system." when we run composer install for the first time. For different versions, just switch it out as appropriate. Most of them are likely the same.

Hope that helps someone.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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