1

I'm having trouble connecting to my databases. It worked a few days ago but can't seem to figure why it doesn't work now. It's a D8-site. Drush version is 8.1.12.

I've double-checked both the alias-file and settings.php-files (both on server & local) and database settings all appear correct. My local site runs on Mamp 4.1.1. and network access is allowed.

Here's the error I get when running sql-sync drush sql-sync @local @dev. Rsync works fine.

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 /vendor/drush/drush/commands/sql/sql.drush.inc:541                [error]
Stack trace:
#0 /vendor/drush/drush/commands/sql/sql.drush.inc(252): drush_sql_get_class()
#1 [internal function]: drush_sql_dump()
#2 /vendor/drush/drush/includes/command.inc(422): call_user_func_array('drush_sql_dump', Array)
#3 /vendor/drush/drush/includes/command.inc(231): _drush_invoke_hooks(Array, Array)
#4 [internal function]: drush_command()
#5 /vendor/drush/drush/includes/command.inc(199): call_user_func_array('drush_command', Array)
#6 /vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(67): drush_dispatch(Array)
#7 /vendor/drush/drush/includes/preflight.inc(66): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#8 /vendor/drush/drush/drush.php(12): drush_main()
#9 {main}
sql-dump failed.

And here's the aliases.drushrc.php (my local copy of course includes credentials:))

<?php

/* Tambourhinoceros Site */

$aliases["local"] = array (
 'root' => '', // local path
 'uri' => 'local.tambourhinoceros.net',  // local uri
 'path-aliases' =>
 array (
   '%dump-dir' => '/tmp',
   '%drush' => '/usr/local/bin',
   '%site' => 'sites/default',
 ),
 'remote-user' => 'tamb_dev', 
 'ssh-options' => '-T',
 'databases' =>
 array (
   'default' =>
   array (
     'default' =>
     array (
        'database' => '', // local database 
        'username' => '', // local database user
        'password' => '', // local database pw
        'host' => 'localhost',
        'port' => '8889',
        'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
);

$aliases["dev"] = array (
  'root' => '', // remote path
  'uri' => 'drupal-85630-297475.cloudwaysapps.com', // remote uri
  'path-aliases' =>
  array (
  ),
  'remote-host' => '', remote IP
  'remote-user' => '', remote User
  'command-specific' =>
 array (
   'rsync' =>
   array (
     'mode' => 'rlptzO',
     'verbose' => true,
     'no-perms' => true,
   ),
 ),
 'databases' =>
 array (
   'default' =>
   array (
     'default' =>
     array (
        'database' => '', remote database
        'username' => '', remote  user
        'password' => '', remote pw
        'host' => 'localhost',
        'port' => '',
        'driver' => 'mysql',
        'prefix' => '',
      ),
    ),
  ),
)
?>
  • 1
    Is it this? drupal.stackexchange.com/questions/186446/… – Clive Jul 25 '17 at 15:44
  • How do I check if it is? I'm not sure what the commands used in that post does... Sorry for being a noob:) – Kristoffer Rom Jul 25 '17 at 16:10
  • Please post the command you typed. – cilefen Jul 25 '17 at 22:05
  • Thanks for pitching in @cilefen. Original question is updated to include the command. – Kristoffer Rom Jul 26 '17 at 6:41
  • What are the relevant drush site alias configurations? – cilefen Jul 26 '17 at 17:05
1

On your local connection, try adding "unix_socket" option and point to your local mysql socket.

$databases['default']['default'] = array (
  'database' => '',
  'username' => '',
  'password' => '',
  'prefix' => '',
  'host' => 'localhost',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
  'unix_socket' => '/var/mysql/mysql.sock',
);

More complete steps to debugging: https://drupal.stackexchange.com/a/174128/25221

  • Sorry, didn't fix it either (using /Applications/MAMP/tmp/mysql/mysql.sock) – Kristoffer Rom Aug 3 '17 at 21:01
  • 1
    Ah well, maybe some of the additional steps for determining the socket in this answer will help. drupal.stackexchange.com/a/174128/25221 – daggerhart Aug 4 '17 at 13:47
  • Thanks @daggerhart. Everything except #5 works. But when running "mysql --socket=/var/mysql/mysql.sock" I get "ysql --socket=/var/mysql/mysql.sock ERROR 1045 (28000): Access denied for user 'kristofferrom'@'localhost' (using password: NO)". The user kristofferrom is my user on my local OS X and the user that MAMP defaults to. Any ideas? – Kristoffer Rom Aug 4 '17 at 20:38
  • 1
    That means you're reaching mysql, but not authenticating with it. You need to pass in info for your mysql user. For example: mysql -u root -p --socket=/var/mysql/mysql.sock then provide your root password when prompted. – daggerhart Aug 6 '17 at 3:44
1

It will be Solved by adding

--root=/full/path/to/your/webroot

to the drush command.

  • Nope, any way to debug why it's not working? – Kristoffer Rom Aug 3 '17 at 15:07
1

Solved. And as usual the issue turned out to be much smaller and simple than I thought...

My local path was missing the "/web" segment in the end. After adding it both rsync and sql-sync works!

Thanks for all the input people.

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.