Hi,
I try to use drush for the first time and I unpacked it and set a symlink to drush in /usr/bin/drush.
Now I can run the command "drush" from any path, but as soon as I run it with additional parameters in my drupal directory odr providing the path to the drupal directory, I get an HTML-output of a drupal page stating "site offline due to connection error to mysql database".
See:
drush cache clear
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="shortcut icon" href="/misc/favicon.ico" type="image/x-icon" />
<title>Site off-line | Drupal</title>
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/defaults.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/system-menus.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/modules/system/maintenance.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/themes/garland/style.css?0" />
<link type="text/css" rel="stylesheet" media="all" href="/themes/garland/minnelli/minnelli.css?0" />
<link type="text/css" rel="stylesheet" media="print" href="/themes/garland/print.css?0" />
<!--[if lt IE 7]>
<link type="text/css" rel="stylesheet" media="all" href="/themes/garland/fix-ie.css" /> <![endif]-->
</head>
<body>
<!-- Layout -->
<div id="header-region" class="clear-block"></div>
<div id="wrapper">
<div id="container" class="clear-block">
<div id="header">
<div id="logo-floater">
<h1><a href="/" title="Drupal"><img src="/themes/garland/minnelli/logo.png" alt="Drupal" id="logo" /><span>Drupal</span></a></h1> </div>
</div> <!-- /header -->
<div id="center"><div id="squeeze"><div class="right-corner"><div class="left-corner">
<h2>Site off-line</h2> <div class="clear-block">
<p>The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.</p><hr /><p><small>If you are the maintainer of this site, please check your database settings in the settings.php file and ensure that your hosting provider's database server is running. For more help, see the <a href="http://drupal.org/node/258">handbook</a>, or contact your hosting provider.</small></p><p><small>The <em>mysqli</em> error was: <em>Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)</em>.</small></p> </div>
<div id="footer"></div>
</div></div></div></div> <!-- /.left-corner, /.right-corner, /#squeeze, /#center -->
</div> <!-- /container -->
</div>
<!-- /layout -->
</body>
</html>
Drush command could not be completed.
All the drupal sites are configured and running on various addresses bound to localhost. I use apachefriend's XAMPP package with apache2 and PHP 5.2.6 on an IMac, the sites running are configured as VHosts and run fine viewed via web browser.
I have the same issue on my MacBook with a similar configuration, so maybe it is a configuration issue on my side?!
Thanks for looking into that
Andi
Comments
Comment #1
jonhattanPerhaps `drush --debug cache clear` output would be of help.
In addition, php exist in two flavours, the apache module and the command line. Drush uses the command line logically. The information you have provided above is for the webserver and could be different for the command line, that has it's own configuration file.
You could also have several php command line executables installed in your system. `drush` command is a wrapper that search for the one to use and invoke `/path/to/php drush.php`. You can perform a phpinfo in the command line with "php -i" but be sure it is the same that `drush` bash script is detecting! :)
Comment #2
pixelmord commentedI tested that and "php -i" ilooks like as it is returning the same infos a phpinfo() on my webserver would return. PHP is 5.2.8...
using the command 'drush --debug cache clear' it reveals that it stops as it looks like at a "headers already sent"-warning.
Here is the code:
Any thoughts on that?
Thanks for your help!
Andi
Comment #3
voipfc commentedI haven't used WAMP for a while but it may be good to test which one you are using.
try
php -v
php-cli -v
php5-cli -v
php5-cgi -v
you won't believe the fun I have had trying these commands on drush installations.
Comment #4
pixelmord commented@voipfc:
You are absolutely right, I don't believe the fun you had ;)
Trying to have some fun myself, I used the mentioned commands and only the first one (php -v) returned something mor than "command not found".
Here is the return:
BUT looking at my previous post, I think that PHP is working for drush because the first tasks in bootstrapping are completed successfully?!
It seems more like running into a problem with the mysql-connection although drush was stating that it did succeed in connecting to the drupal DB. So maybe it is a problem on my MACs that either a permission is not set or drush cannot use mysql-commands because they are not on the PATH or something?
I'm not the most advanced MAC(Unix)-User yet, so sometimes the configuration of the system gives me a hard time.
Comment #5
jonhattanpixelmod: In the debug you pasted this is an interesting part:
Those come from
includes/environment.inc. The first one is at line 790: it does verify that PDO is installed but it fails because mysql driver is not found and it assumes yes and returns TRUE. The "Successfully connected to the Drupal database." comes afterward and is shown because we got TRUE in the verification on the bootstrap phase. What is really happening behind the scenes is that PDO's mysql support is not available but drush don't raises an error.So you must enable mysql support in your php cli. This is my setup:
Comment #6
pixelmord commentedAh I see...
This might be the problem. I noticed on my iMac, that the version installed with my webserver-package(apachefriend's XAMPP) of PHP is 5.2.6 and on the command-line the version info(using the command "php -v") states 5.2.8. I did not notice that on my MacBook, becaue there the versions are the same.
But that indicates, that the command line uses a different PHP version than the webserver. And then it is possible, that the command-line PHP version is not properly(or at all) configured and also not for connecting properly to MySql. I suppose the version used was delivered out of the box with my Macs and MySQL is not contained on a new Mac, that is why I installed the XAMPP-package. Fine.
BUT how can I ( as a former Windows-User :( ) configure the Macs that they use the newly installed PHP(XAMPP) from the command-line or how can I configure the now used PHP(out of the box) that the proper extensions for mysql are activated?
Thanks all for your help!!!!!
Comment #7
jonhattanI dont work with macs. Btw, I figure you can use almost all typical unix commands. You can look for several php executables with
whereis php. Look for the configuration path for each command./path/to/php -iwill tell you.Comment #8
pixelmord commented@jonhattan:
Thank you very much for your help!
The "whereis" helped a lot, I solved my problem with a little brute force:
I renamed the "standard" php in /usr/bin and put a new symlink to the newly installed and properly configured PHP in my XAMPP-package.
Now drush works fine!
I'm sorry but I'm a complete noob in Unix and command-line-adventureland.. ;)
Comment #9
dman commentedThat fix - renaming and symlinking - is good enough.
I went through pain on my Mac, to eventually compile my own php, and still had the apple-distro stunted version of php on the commandline.
running phpinfo also gives you clues pretty quick, as different binaries or contexts can use a different php.ini.
Comment #11
aschiwi commented@pixelmord: good to see you having the same problem as me :) I just got switched from pc to mac and one of the first things I did was install drush. I have the exact same problem and I figure it's because MAMP is using PHP 5.2.13 and the terminal states 5.2.12 as the PHP version in use. Now, it would be great if you could tell me what exactly you did when you "renamed the "standard" php in /usr/bin and put a new symlink to the newly installed and properly configured PHP in my XAMPP-package." (if you still remember) or maybe somebody else could tell me what I would have to do.
Comment #12
aschiwi commentedwith some help I created a file .bash_profile with this content
alias drush='/Applications/MAMP/bin/php5.2/bin/php /usr/local/lib/drush/drush.php'That's all I had to do and now drush works =)
Comment #13
jienckebd commentedI was having the same problem with MAMP Pro 3.4 and Drush 8.0.1. Doing the below fixed it for me:
1) Add the below line to ~/.bash_profile
alias drush='/Applications/MAMP/bin/php/php5.6.10/bin/php /Users/bryan/.composer/vendor/bin/drush.php'2) Run command:
source ~/.bash_profile