---
title: "Troubleshooting Drush error \"Could not load SQL class.\""
date: "2025-02-06T00:07:43+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/92136-troubleshooting-drush-error-could-not-load-sql-class"
id: "00fef563-7d91-4e94-8895-eedf9bcd92e9"
---

**Issue**
---------

When running a **drush** command or script that uses drush, you see errors that look like these:

> _Could not load SQL class. There is a mismatch between your Drupal root and your PHP autoloading.  
> This can happen if you mix Drupal 8 and Drupal 7.  
> Please check that the location of Drush matches the Drupal core version you want Drush to talk to._

**Resolution**
--------------

*   Ensure the composer package **drush/drush** so that it's present in the folder **\[Git repository root\]/vendor/drush/drush**
*   Ensure you have a symlink in **\[Git repository root\]/vendor/bin/drush** that points to **../drush/drush/drush**
    *   _Note: Sometimes the vendor/bin folder does not exist and will need to be created first._

After this, you should now be able to run **drush** from the commandline, and it should pick up on the correct drush version.

### Example steps to show and fix the error

_NOTE: The below output shows steps done ONLY on a local development environment. To fix this on an Acquia environment, you would need to first create the symlink, then commit it to your code repository, and then push that code into your Acquia environment._

    # Step 1: Test drush to show the error.
    # Note: ~/Sites/localsite/mysite is the Git repository root.
    
    ~/Sites/localsite/mysite/vendor/bin (master)$ drush st 
    Could not load SQL class. There is a mismatch between your Drupal root and your PHP autoloading.        [error]
    This can happen if you mix Drupal 8 and Drupal 7.                                                       [error]
    Please check that the location of Drush matches the Drupal core version you want Drush to talk to.      [error]
     Drupal version  :  8.9.6      
     Site URI :  http://default    
    { ... snip ... }
    
    # Step 2: Verify if the vendor/bin/drush symlink exists
    ~/Sites/localsite/mysite/vendor/bin (master)$ ls -l drush
    ls: cannot access 'drush': No such file or directory
    
    # Step 3: Create the missing symlink
    ~/Sites/localsite/mysite/vendor/bin (master)$ ln -s ../drush/drush/drush drush
    
    ~/Sites/localsite/mysite/vendor/bin (master)$ ls -l drush
    lrwxrwxrwx 1 myuser myuser 20 Aug  5 11:26 drush -> ../drush/drush/drush
    
    # Step 4: Test again: error should be gone!
    # NOTE: The "Drush script" line below should show the path to the Drush script in vendor/drush
    ~/Sites/localsite/mysite/vendor/bin (master)$ drush st
     Drupal version   : 8.9.6     
     Site URI  : http://default   
     DB driver : mysql     
     DB hostname : localhost        
     DB port   : 3306      
     DB username : root      
     DB name   : mydatabase      
     Database  : Connected        
    { ... snip ... }
     Drush script     : /home/myusername/Sites/localsite/mysite/vendor/drush/drush/drush