2
votes

I have followed instructions on http://docs.drush.org/en/master/install/ to install Drush (tried both global and individual options).

When I cd to the Drupal site root and type "drush status" I get the following:

 Drupal version         :  7.34
 Site URI               :  http://default
 PHP executable         :  /usr/bin/php
 PHP configuration      :  /etc/php.ini
 PHP OS                 :  Linux
 Drush script           :  /root/.composer/vendor/drush/drush/drush.php
 Drush version          :  7.0.0
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /var/www/site_dev
 Site path              :  sites/default

When I type "drush cc all" I get:

No Drupal site found, only 'drush' cache was cleared.
'all' cache was cleared.    

When I type "drush sqlc" I get:

exception 'ReflectionException' with message 'Class Drush\Sql\Sql7 does not have a constructor, so you cannot pass any constructor      [error]
arguments' in /root/.composer/vendor/drush/drush/includes/drush.inc:113
Stack trace:
#0 /root/.composer/vendor/drush/drush/includes/drush.inc(113): ReflectionClass->newInstanceArgs(Array)
#1 /root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(605): drush_get_class('Drush\Sql\Sql', Array, Array)
#2 /root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(588): drush_sql_get_version()
#3 /root/.composer/vendor/drush/drush/commands/sql/sql.drush.inc(454): drush_sql_get_class()
#4 [internal function]: drush_sql_cli()
#5 /root/.composer/vendor/drush/drush/includes/command.inc(368): call_user_func_array('drush_sql_cli', Array)
#6 /root/.composer/vendor/drush/drush/includes/command.inc(219): _drush_invoke_hooks(Array, Array)
#7 [internal function]: drush_command()
#8 /root/.composer/vendor/drush/drush/includes/command.inc(187): call_user_func_array('drush_command', Array)
#9 /root/.composer/vendor/drush/drush/lib/Drush/Boot/BaseBoot.php(62): drush_dispatch(Array)
#10 /root/.composer/vendor/drush/drush/drush.php(70): Drush\Boot\BaseBoot->bootstrap_and_dispatch()
#11 /root/.composer/vendor/drush/drush/drush.php(11): drush_main()
#12 {main}

It strikes me that the problem has something to do with MySQL (because the status doesn't list the DB parameters), but I can't figure it out. Under sites there is only default folder, so it's not a multisite installation.

Can anyone advise what's wrong please?

UPDATE I have upgraded PHP to 5.5.27 and reinstalled Drush 7.0.0. Following an advice here I deleted my.cnf from the home folder and after that "drush sqlc" started to work, however when I type "drush -v -d status" it gives me:

Starting Drush preflight. [0.01 sec, 2.08 MB]                                                                                           [preflight]
Cache HIT cid: 7.0.0-commandfiles-0-81cc86c1995ab7206f383ec28ad43baf [0.01 sec, 2.14 MB]                                                    [debug]
Bootstrap to phase 0. [0.07 sec, 6.08 MB]                                                                                               [bootstrap]
Drush bootstrap phase : bootstrap_drupal_root() [0.08 sec, 6.43 MB]                                                                     [bootstrap]
Initialized Drupal 7.34 root directory at /var/www/site_dev [0.08 sec, 6.43 MB]                                                           [notice]
Find command files for phase 1 (max=7) [0.08 sec, 4.48 MB]                                                                                  [debug]
Cache HIT cid: 7.0.0-commandfiles-1-a0882f4af91e1d6b72794cc62bb1b558 [0.08 sec, 4.49 MB]                                                    [debug]
Drush bootstrap phase : bootstrap_drupal_site() [0.08 sec, 4.49 MB]                                                                     [bootstrap]
Initialized Drupal site default at sites/default [0.08 sec, 4.5 MB]                                                                        [notice]
Find command files for phase 2 (max=7) [0.09 sec, 4.5 MB]                                                                                   [debug]
Cache HIT cid: 7.0.0-commandfiles-2-f17fc6bdab2f74278df75194ca483893 [0.09 sec, 4.5 MB]                                                     [debug]
Drush bootstrap phase : bootstrap_drupal_configuration() [0.09 sec, 4.5 MB]                                                             [bootstrap]
Find command files for phase 3 (max=7) [0.09 sec, 4.51 MB]                                                                                  [debug]
sql-query: SELECT 1; [0.09 sec, 4.62 MB]                                                                                                [status]
Executing: mysql --defaults-extra-file=/tmp/drush_CKiVHd --database=site_dev --host=localhost --silent  < /tmp/drush_DG1fIs
  1
Drush bootstrap phase : bootstrap_drupal_database() [0.1 sec, 4.62 MB]                                                                  [bootstrap]
Successfully connected to the Drupal database. [0.11 sec, 5.13 MB]                                                                      [bootstrap]
Find command files for phase 4 (max=7) [0.11 sec, 5.13 MB]                                                                                  [debug]
Drush bootstrap phase : bootstrap_drupal_full() [0.11 sec, 5.13 MB]                                                                     [bootstrap]
Cannot modify header information - headers already sent by (output started at /root/.composer/vendor/drush/drush/includes/output.inc:38)[warning]
common.inc:698 [0.96 sec, 31.9 МБ]
Drush command terminated abnormally due to an unrecoverable error.
3
there must be drush version mismatch with that of drupal. drush version 5 works with drupal 7 I guess. - Viswanath Polaki
@ViswanathPolaki I don't think so. At least the official website says Drush 7 is compatible with Drupal 7.x - Alexey
What happens if you type drush sqlc ? - Scott Anderson
@ScottAnderson I have added the output of this command to my post. Thanks - Alexey
@Alexey how did you go with this, was it related to the issue in my answer? - Scott Anderson

3 Answers

3
votes

Sounds like it could be this issue: 7.x does not work with PHP 5.3.3.

There is a solution provided in this comment:

The base class SqlVersion class does not have a constructor and yet an empty array is passed into its descendant (Sql6 or Sql7).

To workaround this, the line:

return $reflectionClass->newInstanceArgs($constructor_args);

should be replaced with:

return !empty($constructor_args) ?
$reflectionClass->newInstanceArgs($constructor_args) :
$reflectionClass->newInstanceArgs();

Alternatively you can upgrade PHP v5.4 or higher.

Or, you can downgrade Drush to 6.x.

0
votes

If you're running this site in your local (dev) environment (hard to tell from the question ...)

then try changing the database host in Drupal's settings.php file from "localhost" to "127.0.0.1".

0
votes

If you're working on Windows, you need to verify that your PATH Variable for MYSQL is properly set. I had the problem when I had upgraded my WAMP.

Example like this : C:\wamp\bin\mysql\mysql5.6.17\bin