Posted by xjm on February 26, 2010 at 7:04pm
34 followers
Jump to:
| 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
* Mac OS 10.6
* Apache and PHP recompiled from source to use PHP 5.2.10
* MySQL and so on installed via macports as per http://drewish.com/node/110
[kepler:/Library/WebServer/Documents/d6 | 13:00:23]$ drush --debug status
Found command: status (commandfile=core) [0.03 sec, 3.46 MB] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_root() [0.03 sec, 3.47 MB] [bootstrap]
Initialized Drupal 6.15 root directory at /Library/WebServer/Documents/d6 [0.03 sec, 4.25 MB] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.03 sec, 4.26 MB] [bootstrap]
Initialized Drupal site default at sites/default [0.03 sec, 4.26 MB] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.03 sec, 4.26 MB] [bootstrap]
PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) environment.inc:939 [0.03 sec, 4.27 MB] [warning]
SQLSTATE[HY000] [2002] No such file or directory [0.03 sec, 4.29 MB][warning]
Drupal Root : /Library/WebServer/Documents/d6
Drupal Version : 6.15
Site Path : sites/default
Site URI : http://default
Database Driver : mysqli
Database Hostname : localhost
Database Username : drupal
Database Name : drupal
Database Password : xxxxxxxxxxx
Default theme : garland
Administration theme : garland
PHP configuration :
Drush Version : All-versions-3.0-beta1
Drush configuration :
Command dispatch complete [0.04 sec, 4.26 MB] [notice]
Timer Cum (sec) Count Avg (msec)
page 0.002 1 2.24
Peak memory usage was 4.34 MB [0.04 sec, 4.26 MB] [memory]My site works fine (no problems with database connectivity); it's just drush commands that fail with this PDO::__construct() error.
I don't think this is a bug in Drush; it seems like it's probably a missing configuration somewhere, but I am not sure what. Any suggestions?
Comments
#1
Hmm, I thought I had downloaded the 2.x version, but apparently not. In either case, I get the same issue with the 2.x release.
#2
probably your CLI PHP uses a different php.ini than the web site does. you have to customize it also.
one quick fix may be to use 127.0.0.1 instead of localhost in your db_url
#3
Using the loopback IP instead of localhost in settings.php worked perfectly, thanks!
#4
I tried changing 'localhost' in my $db_url string to 127.0.0.1, but that ended up throwing a bunch more errors.
My 'solution' was to create a symbolic link to the actual mysql.sock file, like this:
ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sockhowever, there is a great possibility that this isn't a viable long term solution..
#5
Automatically closed -- issue fixed for 2 weeks with no activity.
#6
Can someone please elaborate. This is beyond me where I make the change to reference the MAMP PHP.
#7
I started having this problem shortly after I upgraded to MAMP & MAMP PRO 1.9 which allows you run PHP 5.2 OR PHP 5.3. For me the problem only started happening after I changed my version of PHP, (Even then it didn't start happening right away.)
The solution was indeed to reference the MAMP PHP.
For me, because I had MAMP set to use PHP 5.3, the exact command was
sudo ln -f /Applications/MAMP/bin/php5.3/bin/php /usr/bin/phpHad I set MAMP to use PHP 5.2, the exact command would have been
sudo ln -f /Applications/MAMP/bin/php5.2/bin/php /usr/bin/phpFor folks using older version of MAMP, the exact command is probably just
sudo ln -f /Applications/MAMP/bin/php5/bin/php /usr/bin/phpDon't forget to make it executable.
sudo chmod +x /usr/bin/php#8
Thanks, Zach. Your solution solved the problem nicely.
#9
I'm using OS X 10.6 and MAMP Pro, had similar problems when using drush and changed my .bash_profile as follows which seemed to fix the problem:
alias drush='/Applications/MAMP/bin/php5.2/bin/php /opt/drush/drush.php'export COLUMNS
And drush worked fine for me for a while.
Today I tried to update my site and things didn't go so well. I ran
drush upand drush was able to update the modules without printing an error. When it came to the core, it seems it updated core but when it had to update the database something went wrong...**snip**
Note: Updating core can potentially break your site. It is NOT recommended to update production sites without prior testing.
Do you really want to continue? (y/n): y
Project drupal was updated successfully. Installed version is now 6.16.
Backups were saved into the directory [ok]
/Users/lclusr/wwwroot/example/backup/modules/20100503172700/drupal.
You have pending database updates. Please run `drush updatedb` or [warning]
visit update.php in your browser.
The external command could not be executed due to an application [error]
error.
SQLSTATE[HY000] [2002] No such file or directory [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 :
Drupal version : 6.16
Site URI : http://default
Database driver : mysqli
Database hostname : localhost
Database username : example
Database name : example
Default theme : garland
Administration theme: garland
PHP configuration :
Drush version : All-versions-3.0
Drush configuration:
Drupal root : /Users/lclusr/wwwroot/example
Site path : sites/default
Modules path : sites/all/modules
Themes path : sites/all/themes
File directory path: sites/default/files
%paths : Array
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.
Drush command could not be completed. [error]
Output from failed command : [error]
An error occurred at function : drush_pm_post_pm_update [error]
After this I check my site and it is working, module and core seem to be updated, only I am presented with a message that I need to run updates. I update date the database from within drupal without any issues.
Why aren't the .bash_profile changes I made shown above sufficient?
fyi I tried using 127.0.0.1 but that also broke my site, so I had to change it back to localhost.
I was trying to avoid using the link approach but I guess I'll have to give it a try.
#10
#7 worked excellent for me with one modification (I do not really know what I am doing): I had to first delete the existing file with
sudo rm /usr/bin/phpand then runsudo ln -f /Applications/MAMP/bin/php5.2/bin/php /usr/bin/php. Thanks Zach!Also dont forget to make your mamp php executable.
Lastly the editing the .bash_profile method to reference the php did not work for me (do not know why)
#11
MAMP Pro 1.9
Mac OS X Snow Leopard
Thanks everyone for the info here. I'd like to add one more step, because if you ever delete MAMP, or uninstall it, you are going to lose the stock MAC OS X php executable.
On the Terminal in MAC OS (Snow Leopard), assuming you are configured to be using php 5.2 in MAMP (chg 5.2 for 5.3 if you want to use php 5.3):
In your site's settings.php, set the database line to use "localhost', eg:
[tcl] is the name of my database:
$db_url = 'mysql://root:passwd@localhost/tcl';
(on line 92 or so)
This works!
Joe
http://www.hydeinteractive.com/
#12
That worked beautifully. Thanks Joe!
#13
You don't need to unlink your system php binary to fix this.
The MAMP php directory structure changed, and the drush shell script doesn't reflect this (yet). Drush looks for a MAMP php in /Applications/MAMP/bin/php5/bin, so I just created a symlink to the new location of the MAMP php binary. I'm using 5.2, so replace with 5.3 if necessary.
Create the missing directory:
sudo mkdir -p /Applications/MAMP/bin/php5/binSymlink to the proper binary:
sudo ln -s /Applications/MAMP/bin/php5.2/bin/php /Applications/MAMP/bin/php5/bin/phpMake sure you can execute it:
sudo chmod a+x /Applications/MAMP/bin/php5.2/bin/php#14
Thanks for all the info, could somebody please tell me what do I need to do to revert back to the original MAC OS php when I uninstall MAMP? I seem to have lost it using the "sudo ln -f /Applications/MAMP/bin/php5.2/bin/php /usr/bin/php" command?
Thanks
#15
Oops I totally broke my drush command by using #11 followed by #13 ! Would really appreciate some help reverting back to the original state.
now I am getting:
thanks
#16
puya:
Copy back the stock php binary:
sudo rm /usr/bin/php // <-- assuming you have ls -la /usr/bin/php.stock | grep stocksudo cp /usr/bin/php.stock /usr/bin/php
#13 and #11 are generally mutually exclusive solutions (-;
#17
You should definitely backup your /usr/bin/php before you follow #11 or #13 above, i.e. something like...
cp /usr/bin/php /usr/bin/php.originalIf you've lost your original php, perhaps at a future mac OS update you might get it back? In the interim, why not just reinstall MAMP and use #11 or #13 above? MAMP doesn't need to be running to use the php provided.
#18
#13 works like a champ and is safer than trying to override your stock php links
#19
Hi Guys,
Drush is well documented. I follow this guide from drush's readme.txt:
I use MAMP PRO 1.9, and I set up this in my .bash_profile on my macbook 10.6:
# According to drush readme.txt, fix the right php version. In my case, I use MAMP PRO php 5.2 version.
alias drush='/Applications/MAMP/bin/php5.2/bin/php /usr/local/drush/drush.php'
export COLUMNS
Then everything goes fine. No need to modify /usr/bin/php.
#20
artt,
that only partially works - as described in #9 above. Some simple drush commands may work for you in that setup, however more complex procedures like updating core fail (at least for me... I'm using 10.6 and 1.9 Pro as well).
Try
drush upon a core update, and let us know if that works for you.#21
s4j4n,
You're right, command
drush upfailed and I found some interesting things....snipped...Project drupal was updated successfully. Installed version is now 6.17.
Backups were saved into the directory [ok]
/Users/art/sites/peco222/backup/modules/20100731001758/drupal.
The command could not be executed successfully (returned: env: php: [error]
No such file or directory
, code: <em>127</em>)
An error occurred at function : drush_pm_post_pm_update [error]
I found an error report called "MAMP_php_error_log_MAMP.txt" which listed like this:
[31-Jul-2010 00:22:15] PHP Warning: PHP Startup: Unable to load dynamic library 'MAMP_extension_dir_MAMP/imap.so' - (null) in Unknown on line 0...snipped...
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried
to allocate 901 bytes) in
/Users/art/Sites/peco222/includes/database.mysql-common.inc on line 41
An error occurred at function : drush_pm_post_pm_update [error]
Interestingly, it didn't use the php.ini I set in MAMP PRO 1.9. I checked the manual of MAMP PRO and found that:
That meant there's no chance to employee the php.ini used in MAMP PRO.
php -ito check what php.ini it used, I found it's /Applications/MAMP/conf/php5.2. So I copied php.ini template in MAMP PRO to /Applications/MAMP/conf/php5.2/php.ini.Then, everything worked.
Thanks for your information.
#22
thanks for the suggestions.
#23
#7 worked for me, after much frustration. Read it carefully, especially the bit about making the php executable.
#24
This recently just began happening to me for what seems like absolutely no reason.
I've been happily using drush to download modules and themes on my local machine for drupal sites in git repositories. Yesterday I went to download a module and receieved the following:
PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) environment.inc:952
SQLSTATE[HY000] [2002] No such file or directory
No idea why this is happening and it is very, very annoying. I thought it had to do with the particular site I was working in, but it is every site I have on my computer. In one site/repo on my machine when I run a drush command it cats out an error page instead of giving me any actual drush warnings. Again, no idea why this would be happening.
I don't have the sites' databases on my local machine and I'm not using MAMP; they reside on a development server. Also, my settings.php file has the information for the remote server.
This really just started yesterday and before then everything was working flawlessly. Any ideas before I begin ripping my hair out?
Edit: I'm using the version of php that came with osx 10.6, which is php 5.3, but the server my site is on is using php 5.2. Again, this was all working fine up until a day or two ago.
#25
I think I've solved my problem. Some how the remote server's db information ended up in my local settings.php, which was causing drush to try and connect to a non-existent database. I ended up completely removing settings.php from my repo because it really shouldn't be there anyway.
#26
The quick fix in #2 worked for me
#27
#2 didn't work for me, but #7 did.
#28
Solution #13 worked for me on Snow Leopard + MAMP PRO 1.9
#29
Thanks Zach for #7!
Worked great.
#30
This was extremely helpful, thanks!
#31
@#13
#13 worked great and it doesn't alter your system's php at all..
I just think the last line should read :
chmod a+x /Applications/MAMP/bin/php5/bin/phpsince we are trying to make the symlink executable right?
#32
#9 fixed the problem for me. Thanks. That was extremely un-fun, getting drush to work on my Mac. Finally!
#33
the antnerve method worked for me - thanx
#34
#13 works as well for MAMP 2.0 and Drush.
However, make sure that you are symlinking the proper MAMP 2.0 PHP file:
[Edited to the correct order, but please see #35:]
sudo ln -s /Applications/MAMP/bin/php/php5.2.17/bin/php /Applications/MAMP/bin/php5.2/bin/php#35
#13 & #34 are on the right track but have minor typos...
The correct sequence for MAMP 2.0 (#13) is:
Create the missing directory:
sudo mkdir -p /Applications/MAMP/bin/php5/binSymlink to the proper binary (#34 in reverse order):
sudo ln -s /Applications/MAMP/bin/php/php5.2.17/bin/php /Applications/MAMP/bin/php5/bin/phpMake sure you can execute it (#31):
sudo chmod a+x /Applications/MAMP/bin/php5/bin/phpFor MAMP 1.9, change line 2 to
sudo ln -s /Applications/MAMP/bin/php5.2/bin/php /Applications/MAMP/bin/php5/bin/php#36
I was experiencing this same issue with OS X 10.7 and MAMP PRO 2.0
I upgraded to MAMP PRO from MAMP where everything was working just fine. Here are the updates that I made to get all of my sites running and Drush working again:
MAMP PRO Updates:
increase php memory_limit in two places (256M probably overkill for most)
- file -> edit template -> php 5.3.6
- applicaitons/mamp/bin/php/php5.3.6/conf/php.ini **
increase max_allowed_packet (32M probably overkill for most)
- file -> edit template -> MySQL my.conf
Add the following line to .profile / .bashrc / .bash_profile (whichever) then restart terminal
export PATH=/Applications/MAMP/bin/php/php5.3.6/bin:/Applications/MAMP/Library/bin:$PATHAll of this can be adjusted accordingly for php 5.2.17
Best of luck all!
*UPDATE*
Don't forget to restart your servers after the config updates.
#37
@xtfer: Thanks for correcting me.
I confirm that all the steps in #35 are working correctly for MAMP 2.0.1.
Cheers!
#38
Number #35 works for me but if you upgrade your drush to 4.5 that should solve the problem too.
#39
@altrugon: Upgrading to Drush 4.5 alone did not solve the issue, at least not when moving from MAMP 2.0.1 to 2.0.3. I still had to use #35 life saving tricks.
#40
#7 Worked for me with MAMP Pro 2.0.3 !! :)
I just modified it to be:
sudo ln -f /Applications/MAMP/bin/php/php5.2.17/bin/php /usr/bin/phpThanks, Zach.
#41
confirm that the symbolic link as explained above works for mamp 2.0.3 and osx 10.7.1:
sudo ln -f /Applications/MAMP/bin/php/php5.3.6/bin/php /usr/bin/php
#42
#35 solved it for me.
Drush 4.5
MAMP 2.0.5
OS X 10.6.8
Edit:
My MAMP preference actually was set to use php5.3.6 , so just copying #35 made my setup link to the php5.2.17 php.ini file. So I had to recreate the link to php5.3.6.
#43
Thankyou
Drush now works. Running Lion with MAMP 2
#44
#13 modified to 5.2.17 per #40 worked for me. It wasn't working at first, because I had installed the Acquia Dev environment sometime back and never really worked in it, but my dev environments set up via mamp were using that PHP--a closer reading of 'drush status' from the beginning would have save me some time. ;) I just deleted the Acqui devel environment, and the modified instructions from #13 worked great.
#45
I created a patch for drush here.
Notice that you have to configure the mysql-socket under settings.php as a unix_socket
http://drupal.org/node/1420312
#46
Solution in #7 worked for me too; thanks Zach!
#47
great! thx ZACH! i am using php 5.2 but the directory-name is php5 (not php5.2 as in your example). when TERMINAL told me that there was no directory like the one specified in my first try i only had to correct the path and all worked perfectly. after a day of desparate work the problem finally was solved! thx again!