3

This is my first attempt at installing Drupal using Composer. I have successfully installed Composer and the Drupal Project template, which comes configured with Drush. To install I use

composer create-project drupal-composer/drupal-project:~8.0 {dir} --stability dev --no-interaction

Next, when I try to install Drupal using Drush with

../vendor/bin/drush site-install --db-url=mysql://{username}:{password}@localhost/{database}

I receive this error

Error: Class 'Drush\Sql\Sql' not found in /Users/.../vendor/drush/drush/src/Sql/SqlBase.php on line 81

I have installed Drush and Composer locally. I have tried requiring drush again after the composer install. I have tried using Drush 9.2.3. SO, If I go through the manual install of Drupal, Drush init does run, but any other command other than version gives me

In Connection.php line 149:
SQLSTATE[HY000] [2002] No such file or directory

I'm using:

  • Composer 1.6.5
  • Drush 9.3
  • Drupal 8.4.5
  • 1
    The message Class 'Drush\Sql\Sql' not found indicates that the Drush doesn't understand which driver to use. (Your site-install command looks correct.) Drush is supposed to load the class Drush\Sql\Sql<Driver> - for example Drush\Sql\SqlMysql. Maybe you could run the command with debugging using the "-d" otpion? – hansfn Jun 20 '18 at 7:51
3

Does your password contain a #? Try this test:

<?php

function test_url($url) {
    $message = (parse_url($url) === false)?"parse_url unable to parse url: 
{$url}\n":print_r(parse_url($url),true);
    echo  $message;
}

test_url("mysql://user:password@site/database_name");
test_url("mysql://user:C0mPl3XP4ss@site/database_name");
test_url("mysql://user:Ci)(*$!@@site/database_name");
test_url("mysql://user:pass#word@site/database_name");
?>

The last URL example fails to be parsed. This appears to be coming from

vendor/drush/drush/src/Sql/SqlBase.php:dbSpecFromDbUrl().

I hit the same issue and traced it to a '#' in my MySQL user password. Changed the password to remove the '#' and everything is working.

  • I had the same 'Drush\Sql\Sql' not found problem, and I had a special character in my mysql password, although it wasn't #. In my case it was &, and it passed your test_url. But still when I changed the password to one without special characters the drush site-install went through. – prkos Sep 3 '18 at 23:54

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.