Please double check that all below points are addressed.
- You're running
drush in Drupal root folder or folder containing
mysql command exists (and it's in your
Please note that the database command depends on your database
driver set in your settings file (e.g.
sqlcmd for SQL Server; for details check different classes in Drush's
If the command is missing when running in any folder, make sure path to its binary file is added into your
PATH system variable.
Your PHP has PDO extension enabled (check by:
php -m | grep pdo or
- Your PHP has database extension enabled (e.g.
mysqli) (check by:
php -m | grep mysql).
To investigate what's exactly wrong, run
-v (verbose) and
-d (debug) flags, e.g.
drush -vd status
drush -vd ev "echo 123"
drush -vd cc all
and check for any errors.
mysql extension for PHP PDO is not installed. Check your php.ini to see how you can enable it.
Install database extension (e.g.
mysqli) (as per above 4th point).
For MAMP, see: Drush does not work on my Mac
Since you're using MAMP, make also sure you running the right version of
php binary (check by
which php) and it should point to
/Applications/MAMP/bin/php/php5.X.X/bin/php. If not, please add the path into your
PATH in your rc files (e.g.
# For MAMP (OSX)
PHP_VER="5.6.10" # Or: 5.4.19/5.5.3 (check by: $ ls /Applications/MAMP/bin/php/php*)
For XAMPP for Windows, similar thing, add your
C:\xampp\mysql\bin into your environment variable
drush command fails for some reason, here are the suggested steps to debug drush (shell commands).
- Install and enable PHP
xdebug extension. Verify by
php71 -i | grep xdebug.
- Verify Drupal root, Settings File and Database are present in
Generate trace file:
drush ev "xdebug_start_trace(); drush_drupal_cache_clear_all(); echo xdebug_get_tracefile_name(); xdebug_stop_trace();"
drush ev "xdebug_start_trace(); print_r(_core_site_status_table()); echo xdebug_get_tracefile_name(); xdebug_stop_trace();"
If xdebug is enabled for different PHP version, specify with
If successful, trace output file should be printed at the end, so take a note of it.
Now open and check the trace file.
To test or compare drush output with clean Drupal, you can install new Drupal in empty folder by:
drush -y qd --no-server --core=drupal-8