Hello,

I'm using drush into a zend server deployed drupal 7.52 instance.

Here a drush status command :

 Drupal version         :  7.52
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  127.0.0.1
 Database port          :  3306
 Database username      :  REMOVED
 Database name          :  REMOVED
 PHP configuration      :  /usr/local/zend/etc/php.ini
 PHP OS                 :  Darwin
 Drush script           :  /usr/local/bin/drush
 Drush version          :  8.1.9
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /usr/local/zend/var/apps/http/ehess.local/80/_docroot_
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default

When I run a drush pm-list or others commands where SQL is involved, I'm getting an error, thrown by MySQL client.
Here a drush pm-list --debug

Phar detected. Proceeding to drush_main().
Loading drushrc "/Users/frederichebert/.drush/drushrc.php" into   [bootstrap]
"home.drush" scope. [0.02 sec, 3.68 MB]
Cache HIT cid:                                                        [debug]
8.1.9-commandfiles-0-4a0beb0a3390aad4d2e0cc61aa2247e4 [0.03 sec,
3.72 MB]
Bootstrap to phase 0. [0.14 sec, 8.11 MB]                         [bootstrap]
Bootstrap to phase 6. [0.15 sec, 8.11 MB]                         [bootstrap]
Drush bootstrap phase : bootstrap_drupal_root() [0.15 sec, 8.4 MB][bootstrap]
Initialized Drupal 7.52 root directory at                         [bootstrap]
/usr/local/zend/var/apps/http/ehess.local/80/_docroot_ [0.16 sec,
8.41 MB]
Find command files for phase 1 (max=6) [0.16 sec, 7.13 MB]            [debug]
Cache HIT cid:                                                        [debug]
8.1.9-commandfiles-1-aa00e9888db018cc17107856d4c1ff27 [0.16 sec,
7.13 MB]
Cache HIT cid:                                                        [debug]
8.1.9-annotationfiles-1-cdd957446c39f6742e27d622f53e5e4a [0.16
sec, 7.13 MB]
Drush bootstrap phase : bootstrap_drupal_site() [0.19 sec, 7.14   [bootstrap]
MB]
Initialized Drupal site default at sites/default [0.19 sec, 7.14  [bootstrap]
MB]
Find command files for phase 2 (max=6) [0.2 sec, 7.15 MB]             [debug]
Drush bootstrap phase : bootstrap_drupal_configuration() [0.2 sec,[bootstrap]
7.15 MB]
Find command files for phase 3 (max=6) [0.2 sec, 7.15 MB]             [debug]
sql-query: SELECT 1; [0.2 sec, 7.21 MB]                              [notice]
Executing: mysql --defaults-extra-file=/private/tmp/drush_uFdjcH --database=my_db --host=127.0.0.1 --port=3306 --silent  < /private/tmp/drush_wx4Ljc
  /usr/local/zend/mysql/bin/mysql.client: unknown variable 'defaults-extra-file=/private/tmp/drush_uFdjcH'
Bootstrap to phase 1. [0.21 sec, 7.21 MB]                         [bootstrap]
Bootstrap to phase 6. [0.24 sec, 8.5 MB]                          [bootstrap]
Bootstrap to phase 5. [0.24 sec, 8.5 MB]                          [bootstrap]
Command pm-list needs a higher bootstrap level to run - you will  [error]
need to invoke drush from a more functional Drupal environment to
run this command. [0.24 sec, 8.5 MB]
The drush command 'pm-list' could not be executed. [0.24 sec, 8.5 [error]
MB]
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         :  7.52
 Site URI               :  http://default
 Database driver        :  mysql
 Database hostname      :  127.0.0.1
 Database port          :  3306
 Database username      :  REMOVED
 Database name          :  REMOVED
 PHP configuration      :  /usr/local/zend/etc/php.ini
 PHP OS                 :  Darwin
 Drush script           :  /usr/local/bin/drush
 Drush version          :  8.1.9
 Drush temp directory   :  /tmp
 Drush configuration    :
 Drush alias files      :
 Drupal root            :  /usr/local/zend/var/apps/http/ehess.local/80/_docroot_
 Drupal Settings File   :  sites/default/settings.php
 Site path              :  sites/default

 [0.29 sec, 8.68 MB]

Here what is wrong :

Executing: mysql --defaults-extra-file=/private/tmp/drush_uFdjcH --database=my_db --host=127.0.0.1 --port=3306 --silent  < /private/tmp/drush_wx4Ljc
  /usr/local/zend/mysql/bin/mysql.client: unknown variable 'defaults-extra-file=/private/tmp/drush_uFdjcH'

I've found on the net that --defaults-extra-file option must be defined in first place on the command line, after mysql command name.

When I call this cli command into bash, it works fine :

neo106:default frederichebert$ /usr/local/zend/mysql/bin/mysql.client --defaults-extra-file=/tmp/def.cnf -u root -p
Enter password:

Any idea about this ?

Many thx,

Comments

fhebert created an issue. See original summary.

fhebert’s picture

update :

In fact

neo106:_docroot_ frederichebert$ mysql --defaults-extra-file=/private/tmp/drush_uFdjcH --database=dev_new_ehess_3 --host=127.0.0.1 --port=3306 --silent
/usr/local/zend/mysql/bin/mysql.client: unknown variable 'defaults-extra-file=/private/tmp/drush_uFdjcH'

does not work at all.

neither

neo106:_docroot_ frederichebert$ mysql --defaults-file=/usr/local/zend/mysql/data/my.cnf --defaults-extra-file=/private/tmp/drush_uFdjcH
/usr/local/zend/mysql/bin/mysql.client: unknown variable 'defaults-file=/usr/local/zend/mysql/data/my.cnf'

But neo106:_docroot_ frederichebert$ mysql.client --defaults-file=/usr/local/zend/mysql/data/my.cnf --defaults-extra-file=/private/tmp/drush_uFdjcH works.

It seems odd and mysql related.

In fact mysql cli in Zend Server is a shell wrapper around mysql.client and here what it is :

#!/bin/sh

# this is a small shell wrapper to the MySQL client that passes the --socket arg, along with any other arguments to the mysql client binary.
if [ -f /etc/zce.rc ];then
    . /etc/zce.rc
else
    echo "/etc/zce.rc doesn't exist!"
    exit 1;
fi

$ZCE_PREFIX/mysql/bin/mysql.client --socket=$ZCE_PREFIX/mysql/tmp/mysql.sock "$@"

Should the "$@" be put before --socket option?

I thinks this bug is Zend Server related, isn't it?

helmo’s picture

Status: Active » Closed (won't fix)

This issue was marked closed (won't fix) because Drush has moved to Github.
If this feature is still desired, you may copy it to our Github project. For best results, create a Pull Request that has been updated for the master branch. Post a link here to the PR, and please also change the status of this issue to closed (duplicate).

Please ask support questions on Drupal Answers.

fhebert’s picture

Here the response of Zend Support :

Your assessment is correct - --defaults-extra-file and --defaults-file must indeed be passed as first option. This appears to be an oversight in the mysql shell wrapper, where --socket is passed first, causing the aforementioned options to fail. We have added a record about this in our issue tracker and we expect the bug to be fixed in a future Zend Server release.

In the meantime, as a workaround, you can safely edit the /usr/local/zend/mysql/bin/mysql wrapper and pass all the arguments before --socket. Since there appear to be no requirement for --socket to be first option, this edit shouldn't lead to any issues. Quoted below is the edited line:

$ZCE_PREFIX/mysql/bin/mysql.client "$@" --socket=$ZCE_PREFIX/mysql/tmp/mysql.sock