Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to find a matching SQL Class. Drush cannot find your database connection details. #700

Closed
kenorb opened this issue Jun 27, 2014 · 12 comments

Comments

@kenorb
Copy link
Contributor

kenorb commented Jun 27, 2014

The following command gives me the error:

drush  -y sql-sync @prod @self

drush version 7.0-dev which doesn't work.
drush status indicates that Drupal bootstrap is connected Successful.
Tested with drush 6.1.0 and it works fine.

 $ drush status
 Drupal version                  :  7.28                                                                           
 Site URI                        :  http://default                                                                 
 Database driver                 :  mysql                                                                          
 Database hostname               :  localhost                                                                      
 Database username               :  root                                                                           
 Database name                   :  foo                                                                       
 Database                        :  Connected                                                                      
 Drupal bootstrap                :  Successful                                                                     
 Drupal user                     :                                                                                 
 Default theme                   :  foo                                                                        
 Administration theme            :  seven                                                                          
 PHP executable                  :  /Applications/MAMP/bin/php/php5.5.3/bin/php                                    
 PHP configuration               :  /Applications/MAMP/bin/php/php5.5.3/conf/php.ini                               
 PHP OS                          :  Darwin                                                                         
 Drush version                   :  7.0-dev                                                                        
 Drush temp directory            :  /tmp                                                                           
 Drush configuration             :  sites/default/drushrc.php         
 Drush alias files               :  sites/default/aliases.drushrc.php 
 Drupal root                     :  foo                                   
 Site path                       :  sites/default                                                                  
 File directory path             :  sites/default/files                                                            
 Private file directory path     :  sites/default/private                                                          
 Temporary file directory path   :  /tmp                         
@weitzman
Copy link
Member

weitzman commented Jul 3, 2014

Please post verbose output, and post the alias definition for @prod

@kenorb
Copy link
Contributor Author

kenorb commented Jul 3, 2014

$ drush -vy sql-sync @prod @self
Loaded alias @prod from file src/sites/all/drush/aliases.drushrc.php                                                                                                                                                           [notice]
ssh -p 1022 prod 'COLUMNS=272 drush  --backend=2 --verbose --yes --uri=www-prod --root=/var/www  sql-conf   --all 2>&1' 2>&1                                                                                                                        [notice]
/Applications/MAMP/bin/php/php5.5.3/bin/php /Users/foo/.composer/vendor/drush/drush/drush.php --php=/Applications/MAMP/bin/php/php5.5.3/bin/php  --backend=2 --verbose --yes --root=/Users/foo/src--uri=http://default  sql-conf      [notice]
--all 2>&1
You will destroy data in drupal7 and replace with data from prod/drupal7.
Do you really want to continue? (y/n): y
Starting to create database on Destination.                                                                                                                                                                                                                          [ok]
/Applications/MAMP/bin/php/php5.5.3/bin/php /Users/foo/.composer/vendor/drush/drush/drush.php --php=/Applications/MAMP/bin/php/php5.5.3/bin/php  --backend=2 --verbose --yes --strict=0 --root=/Users/foo/src --uri=http://default     [notice]
sql-create   --sanitize --create-db --cache --structure-tables-key=common --skip-tables-key=common 2>&1
Unable to find a matching SQL Class. Drush cannot find your database connection details.                                                                                                                                                                             [error]
Command dispatch complete                                                                                                                                                                                                                                               [notice]
sql-create failed.                                                                                                                                                                                                                                                   [error]
Command dispatch complete                     


$ drush site-alias @prod --full
$aliases["prod"] = array (
  'uri' => 'www-prod',
  'root' => '/var/www',
  'remote-host' => 'prod',
  'ssh-options' => '-p 1022',
  'path-aliases' => 
  array (
    '%files' => 'sites/default/files',
    '%private' => 'sites/default/private',
  ),
  'command-specific' => 
  array (
    'sql-sync' => 
    array (
      'no-cache' => false,
      'sanitize' => true,
      'structure-tables' => array ('common' => array (0 => 'cache', 1 => 'cache_filter', 2 => 'cache_menu', 3 => 'cache_page', 4 => 'history', 5 => 'sessions', 6 => 'watchdog', ), ),
    ),
    'sql-dump' => 
    array (
      'ordered-dump' => true,
    ),
  ),
  '#file' => '/Users/foo/src/sites/all/drush/aliases.drushrc.php',
  '#name' => 'prod',
);

@weitzman
Copy link
Member

weitzman commented Jul 8, 2014

Can you please post the output of drush @prod status

FYI, ordered-dump option is gone in Drush7, as is no-cache (there is never any caching). sql-sync is tolerant of unused options so you can remove them when you have time and stop using drush6.

@kenorb
Copy link
Contributor Author

kenorb commented Jul 8, 2014

Thanks, I've removed no-cache.

The remote drush is a bit older:

$ drush @prod status
Drupal version                :  7.28                                         
Site URI                      :  www-prod                  
Database driver               :  mysql                                        
Database hostname             :  localhost                                    
Database username             :  foo                                 
Database name                 :  foo                                     
Database                      :  Connected                                    
Drupal bootstrap              :  Successful                                   
Drupal user                   :  Anonymous                                    
Default theme                 :  foo                                      
Administration theme          :  seven                                        
PHP configuration             :  /etc/php5/cli/php.ini                        
Drush version                 :  5.4                                          
Drush configuration           :  /var/www/sites/all/drush/drushrc.php         
Drush alias files             :  /var/www/sites/all/drush/aliases.drushrc.php 
Drupal root                   :  /var/www                                     
Site path                     :  sites/default                                
File directory path           :  sites/default/files                          
Private file directory path   :  sites/default/private                        
temp                          :  /tmp         

Btw. drush help sql-dump still is showing info about --ordered-dump. It would be pity if this would be gone with no alternatives.

@weitzman
Copy link
Member

weitzman commented Jul 9, 2014

Fixed in da0ad8a

@weitzman weitzman closed this as completed Jul 9, 2014
@drd2aiki
Copy link

Getting this error also. Found this thread and wondering what I'm doing wrong. Here's what I'm getting from Drush 8.0-Dev:

dmacbp:~ Dan$ drush sql-sync @www.pmm @local.pmm -y
You will destroy data in local.pmm and replace with data from 50.116.40.202/www.pmm.
Do you really want to continue? (y/n): y
Starting to dump database on Source. [ok]
Database dump saved to /home/Dan/drush-backups/dev.pmm/20150717161739/dev.pmm_20150717_161739.sql.gz [success]
Starting to discover temporary files directory on Destination. [ok]
You will destroy data from /tmp/dev.pmm_20150717_161739.sql.gz and replace with data from Dan@50.116.40.202:/home/Dan/drush-backups/dev.pmm/20150717161739/dev.pmm_20150717_161739.sql.gz
Do you really want to continue? (y/n): y
Copying dump file from Source to Destination. [ok]
Starting to import dump file onto Destination database. [ok]
Unable to load class Drush\Sql\Sql [error]
exception 'Drush\Sql\SqlException' with message 'Unable to find a matching SQL Class. Drush cannot find your database connection details.' in [error]
/Users/Dan/.composer/vendor/drush/drush/commands/sql/sql.drush.inc:595
Stack trace:
#0 /Users/Dan/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(428): drush_sql_get_class(NULL)
#1 [internal function]: drush_sql_query()
#2 /Users/Dan/.composer/vendor/drush/drush/includes/command.inc(359): call_user_func_array('drush_sql_query', Array)
#3 /Users/Dan/.composer/vendor/drush/drush/includes/command.inc(210): _drush_invoke_hooks(Array, Array)
#4 [internal function]: drush_command()
#5 /Users/Dan/.composer/vendor/drush/drush/includes/command.inc(178): call_user_func_array('drush_command', Array)
#6 /Users/Dan/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
#7 /Users/Dan/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 /Users/Dan/.composer/vendor/drush/drush/drush.php(11): drush_main()
#9 {main}

@jenlampton
Copy link

I'm also seeing the error Unable to load class Drush\Sql\Sql. I checked drush 7-dev and confirmed that the fix from da0ad8a has been included. Not sure where to look next. Where is this class (I don't see it in the codebase)?

@jonhattan
Copy link
Member

@jenlampton this starts in drush_sql_get_version(), but please keep in mind that if you're hacking the code to make backdrop work, you may encounter illegitimate errors.

@jiv-e
Copy link

jiv-e commented Oct 30, 2015

I got this error because I had a wrong site root path in my Drush alias definition. So be sure to double check that if you get this!

@eckersley
Copy link

I laboured over this error too; the root path seemed perfectly fine in the alias file - until I realized that my home directory was not the same as the one being used by sql-dump. I had to spell out ~/Sites/ from the root, as in /Users/[My_Username]/[Drupal_Installation]. I could finally get a read on the databases in drush @[sitename].local status and perform drush @[alias].remote @[sitename].local

@briantully
Copy link

@eckersley thank you!!! Indeed it seems the home directory cannot be specified with the "~" prefix and instead must be specified as the full path, otherwise drush will frown upon the site alias. I too wasted so much time on this, and could have wasted even more time -- but thankfully I saw your comment 👍

@phanos
Copy link

phanos commented Jun 23, 2017

I ran into this same problem after a drush rsync when I failed to notice my sites/default/settings.php was not copied

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants