Download & Extend

Drush breaks with zend server

Project:Drush
Version:All-versions-3.0-beta1
Component:PM (dl, en, up ...)
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

I have recently tried out the zend sever community edition for performance benefits over standard php within ubuntu. So far drupal works fine with the exception of drush. it seems that is is unable to bootstrap drupal. drush --debug cron gives this:

$ drush --debug cron
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.04 sec]                                          [bootstrap]
Initialized Drupal 6.13 root directory at /var/www/drupal/shamce.net [0.064 sec]                              [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.064 sec]                                         [bootstrap]
Initialized Drupal site default at sites/default [0.156 sec]                                                  [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.156 sec]                                [bootstrap]
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) [0.16 sec] [warning]
Drush was not able to start (bootstrap) the Drupal database.                                               [error]
Hint: This error often occurs when Drush is trying to bootstrap a site that has not been installed or does
not have a configured database.

Drush was attempting to connect to :
  PHP configuration : /usr/local/zend/etc/php.ini
  Drupal Root       : /var/www/drupal/shamce.net
  Drupal version    : 6.13
  Site Path         : sites/default
  Site URI          : http://default
  Database Driver   : mysqli
  Database Hostname : localhost
  Database Username : dbadminshamce
  Database Name     : master_shamce
  Database Password : gf6rde^&5R8&t987(8Ij)(79_(j0ij08(&t(87

You can select another site with a working database setup by specifying the URI to use with the --uri
parameter on the command line or $options['uri'] in your drushrc.php file.
[0.164 sec]
Command cron needs a higher bootstrap level to run - you will need invoke drush from a more functional     [error]
Drupal environment to run this command. [0.164 sec]
The command 'drush.php cron' could not be executed. [0.164 sec]                                            [error]

This may be due to the fact that to install zend you have to remove the normal php installation as it is a replacement. Some of the bins might be in a different location. But I have installed the bin/lib paths into the local path and should be available normally. Other than that im not sure quite yet what is breaking it. it gives the error " Can't connect to local MySQL server through socket '/tmp/mysql.sock' " but it doesnt make sense as im able to use my site normally so mysql is working fine.

any ideas? thanks in advance

Comments

#1

Version:All-versions-5.x-dev» All-Versions-2.0

Oops, marked wrong version

#2

a dummy question. Is your mysql server running?

another one: php is trying to connect mysql via socket `/tmp/mysql.sock`. Is that your mysql server socket path? you can see the path mysql is using with mysqladmin --print-defaults.

#3

You can also check if php has a value for the mysql socket with php -i |grep mysql.*socket.

#4

Status:active» postponed (maintainer needs more info)

#5

$ mysqladmin --print-defaults
mysqladmin would have been started with the following arguments:
--port=3306 --socket=/var/run/mysqld/mysqld.sock --user=dbadminshawn --password=v5JYvi4efvjhyR7hY5rEygbtYufyhhh8787HHK --socket=/var/run/mysqld/mysqld.sock

$ php -i |grep mysql.*socket
mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
mysqli.default_socket => no value => no value

Ok so my sockets path is: /var/run/mysqld/mysqld.sock
According both above that is my path, so im not sure why drush is seeing that path of /tmp/mysql.sock . Also for reference when using zend the php.ini file is located at: /usr/local/zend/etc/php.ini

I am running Ubuntu Jautny Server 9.04, the zend-pe package was downloaded with 'sudo apt-get install zend-pe'

#6

bigmack83: can you double check that you're using the same php executable for drush and for above tests?

php -i |grep "Configuration File"

If so, you could also try to hardcode the socket path in the corresponding php.ini.

#7

Version:All-Versions-2.0» All-versions-3.0-beta1
Status:postponed (maintainer needs more info)» active

I have the same issue with the latest Drush version and the latest Zend Server CE (5.0) on a Mac 10.5

$ mysqladmin --print-defaults
mysqladmin would have been started with the following arguments:
--port=3306 --socket=/usr/local/zend/mysql/tmp/mysql.sock

$ php -i |grep mysql.*socket
mysql.default_socket => /usr/local/zend/mysql/tmp/mysql.sock => /usr/local/zend/mysql/tmp/mysql.sock
mysqli.default_socket => /usr/local/zend/mysql/tmp/mysql.sock => /usr/local/zend/mysql/tmp/mysql.sock

$ php -i |grep "Configuration File"
Configuration File (php.ini) Path => /usr/local/zend/etc
Loaded Configuration File => /usr/local/zend/etc/php.ini

When I run drush status I get following result:
$ drush status
SQLSTATE[28000] [1045] Access denied for user 'localuser'@'localhost' (using password: YES) [warning]
Drupal Root : /Volumes/www/00-vhosts/ovg/trunk/openAtrium/http
Drupal Version : 6.14
Site Path : sites/default
Site URI : http://default
Database Driver : mysql
Database Hostname : localhost
Database Username : localuser
Database Name : dp_ovg_atrium
Database Password : localpass
Default theme : garland
Administration theme : garland
PHP configuration : /usr/local/zend/etc/php.ini
Drush Version : All-versions-3.0-beta1
Drush configuration :

The Drupal installation works fine.

#8

Status:active» fixed

I did some extra search and debug work today: I found the solution!

Drush doesn't use the mysql or mysqli libraries to validate the connection, it uses PDO (diving in somebody else's code is fun!).
This worked fine on my ZS ce 4 setup, upgrade to ZS 5 broke it.

The problem is that ZS uses a custom (non default MySQL) to store the mysql socket (/usr/local/zend/mysql/tmp/mysql.sock).
In the php.ini you can specify the socket path for mysql and mysqli libraries, for pdo_mysql you can only do that if you have installed php5.3.x

So what is the sollution:
Edit the mysql config (/usr/local/zend/mysql/data/my.cnf) and changes all socket locations to /tmp/mysql.sock
[client]
#password = your_password
port = 3306
#bind-address = 127.0.0.1
#CHANGED!
socket = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3306
#CHANGED!
socket = /tmp/mysql.sock

Edit the php config (/usr/local/zend/etc/php.ini) and change all socket locations to /tmp/mysql.sock
[MySQL]
...
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /tmp/mysql.sock

...

[MySQLi]
...
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysqli.default_socket = /tmp/mysql.sock

Restart apache (sudo /usr/local/zend/bin/zendctl.sh restart-apache)
and mysql (sudo /usr/local/zend/bin/zendctl.sh restart-mysql)

Test it => works!

#9

a symlink from the mysql/mysqli location to the PDO location would also work. thanks for the detective work.

if anyone has ideas on how we should improve this, please speak.

#10

Hm; if drush fails to bootstrap the database, check to see if the string 'zend' appears in the path to php.ini, and print an advisory warning if so?

Somehow it doesn't feel right to have drush try and fix or adapt to the situation, but maybe we could have it tell the user what to do.

#11

I get all this when execute Drush with Zend:

PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/curl.so' - /usr/lib/php5/20060613/curl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/gd.so' - /usr/lib/php5/20060613/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/ldap.so' - /usr/lib/php5/20060613/ldap.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/mcrypt.so' - /usr/lib/php5/20060613/mcrypt.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/mysql.so' - /usr/lib/php5/20060613/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/mysqli.so' - /usr/lib/php5/20060613/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20060613/pdo_mysql.so' - /usr/lib/php5/20060613/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0

and it doesnt work, of course.

Anyone can help me, please?

#12

I get this too.

$ php --version
PHP 5.1.6 (cli) (built: Jul 16 2008 19:52:52)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

$ drush
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/dbase.so' - /usr/lib/php5/dbase.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/mysql.so' - /usr/lib/php5/mysql.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/mysqli.so' - /usr/lib/php5/mysqli.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/pdo.so' - /usr/lib/php5/pdo.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/pdo_mysql.so' - /usr/lib/php5/pdo_mysql.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/pdo_sqlite.so' - /usr/lib/php5/pdo_sqlite.so: wrong ELF class: ELFCLASS64 in Unknown on line 0
Execute a drush command. Run `drush help [command]` to view command-specific help.

Examples:
drush dl cck zen Download CCK module and Zen theme.
...

#13

Status:fixed» closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

#14

To isiden & azuledu:

Those issues are not exactly related to the database connectivity.. but read this to learn how you can fix them for Mac OS + Zend Server + drush: http://forums.zend.com/viewtopic.php?f=8&t=792

This is what worked for me:
---------------------

sudo nano /etc/profile

# Add the lines to correct shell variables for drush Zend Server
. /private/etc/zce.rc
PATH=$PATH:/usr/local/zend/bin
export PATH

// Update profile for current terminal (without restart)
source /etc/profile

// Test php. Shouldn't whine about dynamic libraries anymore.
php -v

If mysql.sock still complains, you probably need to fix mysql.sock in my.cnf, or just with:
ln -s /usr/local/zend/mysql/tmp/mysql.sock /tmp/mysql.sock

(I actually put this in my profile, because the symlink gets deleted at boot:
alias fixdrush='ln -s /usr/local/zend/mysql/tmp/mysql.sock /tmp/mysql.sock'
)

PS: thx for the db fix.

EDIT: fixed type /urs/ --> /usr/ and added note on mysql.sock

#15

I think this issue is not really "fixed", although there is not much the drush developers can do. Maybe one little thing: Since the drush wrapper script tries to accomodate for specific distributions like MAMP, it might be necessary to also include checks for Zend server. Most of the problems described here in this thread stem from the combination of Zend (=php 5.2) & Debian, but users of other combinations have reported similar problems.

I had a default Debian setup (php and apache2 out of the box) with
a working drupal6 installation and a drush setup that worked. After installing and enabling Zend, the drupal6 website
was still alive without problems. Drush was broken from then on. Here's why:

1) If installing Zend Server ($$ edition) on Debian, you end up with two
php versions - the "default" debian one and the zend one in /usr/local/zend/bin
However, since Zend overrides some, but not all configs and extension paths, you end up
with a broken Debian-CLI-php. So if you try to call "drush" after Zend installation while
still using your old PATH settings, this will most likely lead to missing .so library error
messages from php, which won't even start. To fix: see (2)

2) Whichever version of php is used for drush is determined by your PATH. So to be
sure that the zend php binary is used, i did
  export PATH=/usr/local/zend/bin:$PATH
Now it should be possible to start php ( do "php -i" and check whether the Zend binary
is used)

Result: now you can run php, but still get /tmp/mysql.sock errors from drush.

3) The Zend binary, although delivered as a debian package, has a compiled constant
for the mysql sockets : /tmp/mysql.sock. This is, in my opinion, a failure on their end because
if they package for Debian there should be the debian path compiled in)
So whatever you put in your .ini-File won't work for drush. See here:

/usr/local/zend/bin/php -i |grep sock
MYSQL_SOCKET => /tmp/mysql.sock
mysql.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock
MYSQLI_SOCKET => /tmp/mysql.sock
mysqli.default_socket => /var/run/mysqld/mysqld.sock => /var/run/mysqld/mysqld.sock

I think this is due to the fact that drush uses PDO which is not using the .ini value,
but the compile time value for the socket

4) Zend is still at php 5.2.13, while AFAIK PDO can be told to accept other socket paths
only >= php 5.3

So now what? For drush users it means using workarounds, until Zend switches
to 5.3 or changes the compile time settings: either symlinking /tmp/mysql.sock or changing the drupal database settings
from localhost to 127.0.0.1 to circumvent local socket usage at all .

Another note on Zend on Debian: the community edition includes the complete stack with
apache and php packages, so there is not much interference with the rest of the system,
while the $$ edition only tries to replace the php packages and can cause confusion
in combination with the debian php packages. At least thats what happened to me.

Regards,
Ulrich

#16

Component:Code» PM (dl, en, up ...)

Yeah the easiest thing I found to do was just symlink /tmp/mysql.sock to /var/run/mysqld/mysqld.sock:

cd /tmp
ln -s /var/run/mysqld/mysqld.sock mysql.sock

#17

subscribing

#18

My new mac and I love this list of workarounds. Thanks folks.

on my mac I did:

cd /tmp
ln -s /usr/local/zend/mysql/tmp/mysql.sock mysql.sock

This lets you type mysql from the terminal and login to mysql that way.

Then I did:

cd /var
mkdir mysql
ln -s /usr/local/zend/mysql/tmp/mysql.sock mysql.sock

and this finally got drush working

to be thorough on documenting this to connect to the zend version of mysql you connect with this line

/usr/local/mysql/bin/mysql -u root -p

but you can always mess around some more to make just typing mysql from the terminal open up the zend version of mysql. I may do this if it annoys me enough.

Cheers,

James

#19

If you have PHP 5.3.x or newer, you can do the following:

sudo nano /usr/local/zend/etc/php.ini

Scroll down to [Pdo_mysql]

Comment out this line by putting a semicolon in front:
;pdo_mysql.default_socket= /usr/local/zend/mysql/tmp/mysql.sock

Under the line that you just commented out, add this line:
pdo_mysql.default_socket= /tmp/mysql.sock

Save the file and restart Zend
sudo /usr/local/zend/bin/zendctl.sh restart

Try a drush command from the Drupal folder and it will work.

#20

I'm using drush on a zend server (based on a kubuntu workstation), changing the database host from "localhost" to "127.0.0.1" solved also the "/tmp/mysql.sock" problems, but was only quoted by uli:

So now what? For drush users it means using workarounds, until Zend switches
to 5.3 or changes the compile time settings: either symlinking /tmp/mysql.sock or changing the drupal database settings
from localhost to 127.0.0.1 to circumvent local socket usage at all .

You should try this first, instead of symlinking the socket to the temporary directory!

nobody click here