4

I installed Drush 7 using Composer, and I created a Drupal 8 running on XAMPP on Windows.

  1. H:\xampp\htdocs\d8_test is the Drupal root.
  2. Location of settings.php file is H:\xampp\htdocs\d8_test\sites\default\settings.php.

None of the drush commands are working. All are failing with the same error:

H:\xampp\htdocs\d8_test>drush pmi
Command pm-info needs a higher bootstrap level to run - you will need    [error]

to invoke drush from a more functional Drupal environment to run this
command.
The drush command 'pmi' could not be executed.                           [error]

Drush was not able to start (bootstrap) the Drupal database.             [error]

Hint: This may occur when Drush is trying to:
 * bootstrap a site that has not been installed or does not have a
configured database. In this case you can select another site with a
working database setup by specifying the URI to use with the --uri
parameter on the command line. See `drush topic docs-aliases` for
details.
 * connect the database through a socket. The socket file may be
wrong or the php-cli may have no access to it in a jailed shell. See
http://drupal.org/node/1428638 for details.

Drush was attempting to connect to:
 Drupal version        :  8.0-dev
 Site URI              :  http://default
 Database driver       :  mysql
 Database username     :  root
 Database name         :  d8_test
 PHP executable        :  php.exe
 PHP configuration     :  H:\xampp\php\php.ini
 PHP OS                :  WINNT
 Drush version         :  7.0-dev
 Drush temp            :  Z:\Temp
 directory
 Drush configuration   :
 Drush alias files     :
 Drupal root           :  H:/xampp/htdocs/d8_test
 Site path             :  sites/default
 Active config path    :  sites/default/files/config_MoeSD5C7JSguok
                          xrBh4-UuwT_r9_jk2Z59QKdN-j9Zx9DIgHBy2dH8n
                          1rGOeKNJpaAAxBi4PzA/active
 Staging config path   :  sites/default/files/config_MoeSD5C7JSguok
                          xrBh4-UuwT_r9_jk2Z59QKdN-j9Zx9DIgHBy2dH8n
                          1rGOeKNJpaAAxBi4PzA/staging

Contents of my settings.php

$databases['default']['default'] = array (
  'database' => 'd8_test',
  'username' => 'root',
  'password' => '',
  'prefix' => '',
  'host' => '127.0.0.1',
  'port' => '3306',
  'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql',
  'driver' => 'mysql',
);

Note that host of my MySQL installation is 127.0.0.1 instead of localhost.

Also note that H:\xampp\php\ is added to my PATH variable, so php.exe refers to H:\xampp\php\php.exe.

The output of drush sql-connect is the following:

mysql --user=root --password= --database=d8_test --host=127.0.0.1 --port=3306

19

The output of drush sql-connect is mysql --user=root --password= --database=d8_test --host=127.0.0.1 --port=3306. Now, when I directly execute this command, it didn't work because mysql.exe was not there in the system PATH. So I added H:\xampp\mysql\bin to PATH (environment variable in Windows) and then it worked!

| improve this answer | |
5

Make sure mysql-client-core-5.5 package is installed.

On Ubuntu:

sudo apt-get install mysql-client-core-5.5
| improve this answer | |
  • 3
    I had forgotten that (since the MySQL database was running on a separate server) drush requires the mysql-client package to connect. Just had to install that, and drush commands are working normally! – geerlingguy Feb 28 '15 at 20:49
  • I had the same problem. – Johan Haest Jun 20 '15 at 11:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.