I finally got Drush up on my new MAC with MAMP running. After running drush status I got....
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through [warning]
socket '/Applications/MAMP/tmp/mysql/mysql.sock' (2)
Drupal version : 6.16
Site URI : http://default
Database driver : mysqli
Database hostname : localhost
Database username : root
Database name : riku
Default theme : garland
Administration theme : garland
PHP configuration : /Applications/MAMP/conf/php5/php.ini
Drush version : All-versions-3.0
Drush configuration :
Drupal root : /Applications/MAMP/htdocs/riku
Site path : sites/default
Jeff-Williamss-iMac:riku HomeFolder$ dl views
-bash: dl: command not found
Jeff-Williamss-iMac:riku HomeFolder$ ccc
any help would be most apreciated
Comments
Comment #1
greg.1.anderson commentedUse "drush dl views" and "drush cc all", for example. If you want to use just the drush command, first go into cli mode via "drush cli". From inside the drush shell you will be able to use just "dl views" and "cc all".
Comment #2
puregin commentedI am seeing the same error message.
I believe this is due to a 'non-standard' location for our mysql socket, /var/lib/mysql/mysql.sock' rather than the one indicated in the error message.
From my brief reading of the PDO documentation, this should be picked up by PDO reading the mysql configuration, but this evidently is not happening.
There doesn't seem to be any 'nice' way to supply this information via configuration files, so I added it to the database connection string in includes/environment.inc as a work-around. After this, everything works fine.
I'm not sure where/how this should be fixed...
Comment #3
greg.1.anderson commentedWhat change did you make to environment.inc?
Comment #4
puregin commentedThis is purely a hack, but it worked for me
Comment #5
vb commentedThe issue is following.
If you have installed anorther development LAMP package like LAMPP or I see here MAMP.
The drush takes by default its parameters php.ini and unix_socket
For lampp
vb@vb:~/www/omegasocial.net$ drush status
SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket [warning]
'/opt/lampp/var/mysql/mysql.sock' (2)
+----------------------+----+------------------------------+
| Drupal version | : | 6.16 |
| Site URI | : | http://default |
| Database driver | : | mysqli
| PHP configuration | : | /opt/lampp/etc/php.ini
For MAMP see the output above
PHP configuration : /Applications/MAMP/conf/php5/php.ini
The services for lampp mysql and apache2 are not started at all. lampp is simple untared and does not have installation procedure that changes something.
On the ubuntu 10.04 native apache2 with php 5.3.2 and mysql are started and running.
But drush does not take their parametres. it takes the first ones that it finds in paths.
And I want that drush is using them but not the lampp's php 5.2.9 and mysql when lampp is not started.
How these parameters can be configured in drush?
Comment #6
greg.1.anderson commentedI didn't really understand the question in #5. If the change in #4 is generally useful, we could add the ability to set
$option['mysql-socket'] = '/var/lib/mysql/mysql.sock'in your drushrc.php file.Comment #7
vb commentedI am using php 5.3.2 for development of 5.3 apps and lampp-1.7.1 with php 5.2.9 to develop 5.2 apps.
Drush is using the first php.ini it found /opt/lampp/etc/php.ini but should use /etc/php5/cli/php.ini or something configurable.
Download lampp http://www.apachefriends.org/en/xampp-linux.html, simple untar it in /opt, do not start it.
Run the drush to your last site as usual.
See the difference.
#6 would be nice to fix the mysql socket issue. Make so with php.ini $option['php-ini'] = /etc/php5/cli/php.ini
Comment #8
greg.1.anderson commentedRegarding your suggestion in #7, I really don't think that's possible; php loads php.ini before drush gains control, and I doubt that you can reload your own. That would be a security violation.
It would be possible in theory to add a --php-ini flag to the invocation of php at the end of the
drushscript, but I'm not really sure where you'd pull the right option from. To me, it seems much easier to just put the correct configuration options in the php.ini file that happens to be in use on your system (/opt/lampp/etc/php.ini).Comment #9
vb commentedI have found the place where it happens.
Please look at drush script line 37
It would be convenient to have the options to skip this test.
Comment #10
greg.1.anderson commentedHow are we supposed to know which php to run on your system? That script does the special checking for *AMP because php is usually newer in the *AMP installations. Now my basic answer to your request is that the "parameter" you should set is $PATH. Unfortunately, that doesn't work because of line 37, which was put in as a service for users who do not set their $PATH. I'm not sure that this was necessarily the best decision, but I'm reluctant to change that now, because I think doing that would break a lot of people.
Adding a flag to the drush script doesn't seem like a good option.
I would recommend that you just make an alias:
alias drush='/path/to/my/php/php /path/to/my/drush/drush --php="/path/to/my/php/php"'Untested, but you get the general idea.
Comment #11
greg.1.anderson commentedWait, this is still active per #4.
Comment #12
moshe weitzman commenteddupe of #437642: support for different MYSQL socket. i really don't see that is is drush's responsibility to allow configuration of the db connection like socket. core drupal does not allow that to be configured afaik. you gotta use the config that php provides.
Comment #13
s4j4n commentedIf drush should be using the php.config file, why is it not using the mysql socket provided in it? Can we have it take advantage of that information?
I think this would be useful for example when running: drush sql-dump
I definitely like the idea of using the config that PHP provides.
The php.ini file that is used by php in MAMP
/Applications/MAMP/conf/php5.2/php.inishows this on line 620:I have MAMP installed. I'm using the symbolic link approach to get drush to work with my MAMP installation by using the php in MAMP.
If I run
php --iniI receive this:All has been good (commands like
drush cron,drush status, ordrush ccwork just fine for me) until recently I tried to rundrush sql-dumpand I'm getting a 2002 error:If I run sql-dump in debug mode one of the lines you see are:
So looks like drush is using the mysqldump in my $PATH (i.e. /sw/bin/mysqldump) instead of MAMP's version at /Applications/MAMP/Library/bin/mysqldump
It's also not using the specified socket listed in php.ini.
Can we have drush use the socket listed in php.ini (assuming there are no compatibility problems with using different mysqldumps)?
Comment #14
craigmc commentedSadly, hack in #4 is all that is working for me thus far in Ubuntu 10.04 headless server running on Zend CSE.
Subscribing.
Comment #15
hansrossel commentedI had the same issue when I started using a normal php/mysql setup on ubuntu instead of xampp: drush status kept on pointing to /opt/lampp/php/php.ini and socket could not connect.
Reason was that I had not installed php-cli:
sudo apt-get install php5-cli
This solved all problems.
So this issue might be a duplicate of http://drupal.org/node/738038#comment-2721536, that issue happened when I removed the xampp installation so drush had no more wrong php to point at.
Comment #16
Bill Choy commentedMy work-around was to create a soft link from where Drush expected the socket, to where my MAMP's "Start page" said it was.
Here the step-by-step (sometimes I need everything spelled out):
1. start your MAMP
2. click on "Open start page" button.
3. copy the socket location (in my case: "/Applications/MAMP/tmp/mysql/mysql.sock")
4. open a UNIX terminal and confirm
"ls -al /Applications/MAMP/tmp/mysql/mysql.sock"
=> srwxrwxrwx 1 williamchoy admin 0 Oct 11 11:39 /Applications/MAMP/tmp/mysql/mysql.sock
(the "s" is for socket).
5. try a drush command (drush pm-list) and get the expected location from the error message and confirm that it does not exist (step 4).
=> In my case it was "/tmp/mysql.sock".
6. create the soft link
"ln -s /Applications/MAMP/tmp/mysql/mysql.sock /tmp/mysql.sock"
7. Test again... and buy a friend a beer, because it is time to party with DRUSH.
Comment #17
joehudson commentedI just commented out the lines:
in the drush script and it all behaved as expected for my standard lamp setup.
Comment #18
joehudson commentedComment #19
candy13 commentedA quick solution, inspired by #4, is to open "advanced options" on the web page and set the host to (in my case)
localhost;unix_socket=/tmp/mysql.sock(ooh, maybe not for drush - sorry, new, & setting up drupal for the first time)
Comment #20
staze commentedThis would be extremely useful, as this is still broken and requires hacking environment.inc to get things to work right. I'm not sure why this doesn't work. My setup has the mysql.default_socket set correctly (/var/mysql/mysql.sock), but drush continues to look for it at /tmp/mysql.sock.
Comment #21
lakshminp commentedpoint the DRUSH_PHP to the php you want to use.
$ export DRUSH_PHP=/path/to/your/phpComment #22
jrabeemer commented#21 worked for me!
Comment #23
crossfish commented#21 did not work for me.
scotts-imac:mwfprod scott$ php --ini
Configuration File (php.ini) Path: /Applications/MAMP/conf/php5.3
Loaded Configuration File: /Applications/MAMP/conf/php5.3/php.ini
Scan for additional .ini files in: (none)
Additional .ini files parsed: (none)
Tried this:
scotts-imac:mwfprod scott$ export DRUSH_PHP=/Applications/MAMP/bin/php5.3/bin/php
scotts-imac:mwfprod scott$ drush sql-dump --file=mwfprod.sql
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/opt/local/var/run/mysqld/mysqld.sock' (2) when trying to connect
drush commands on my system seem to work okay for the most part, but the sql-dump croaks for sure in using mysqldump. In #16 above, line 5. seems to indicate an error should occur, but my pm-list comes out nicely, so I didn't try to setup the soft link to '/tmp/mysql.sock'.
I did this:
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock /opt/local/var/run/mysqld/mysqld.sock
and got a good execution. However, I may have broken something else in the process and I'll have to report that later if/when I come across it.