I was getting the following error message after executing the drush command, drush statusmodules. (Hopefully it will work (fix) in the same way with other drush command as well.)
Full text of the error message I received is as follows:
Command statusmodules needs a higher bootstrap level to run - you will need invoke drush from a more functional Drupal environment to run this command.
The command 'drush.php sm' could not be executed.
I used the following post as reference:
http://www.hazelconsulting.com/blog/troubleshooting-drush-bootstrap-loca...
So, I modified the settings.php file, and changed the following line.
From:
$db_url = 'mysqli://moses:mosespass@localhost/groups
To:
$db_url = 'mysqli://moses:mosespass@127.0.0.1/groups
And the problem went away.
Seems like a drush issue that needs to be fixed, and localhost should be an accepted alias for the IP address 127.0.0.1.
Comments
Comment #1
greg.1.anderson commentedInteresting; I use 'localhost' in my $db_url, and it works just fine (using drush-HEAD from today). Check the network settings on your machine (e.g. make sure you have
127.0.0.1 localhostin your /etc/hosts file if you are on Linux) -- although I presume your db settings work from Drupal?Also, please note that Drush 2.1 is no longer actively maintained. You could try drush-3.0-alpha-1 and see if that works better for you. We are working towards a stable release of drush 3; sorry for any inconvenience.
Comment #2
owen barton commentedI think we have seen this issue before.
This is probably occurring because php is trying to connect to mysql via a socket and does not have permission to (or the socket is broken), replacing localhost with 127.0.0.1 forces it to use an IP connection, and hence it succeeds. Why it would work from the web, but not cli is probably either because the php web user has permissions to access the socket, or because the web php.ini a difference causing it to use IP connections.
Comment #3
greg.1.anderson commentedHm, yes, that makes sense. I'm using postgres, so I wouldn't see mysql issues in any event.
Anyway, this doesn't look like a drush issue, so I'll close it.
Comment #4
momo18 commentedRegarding my original post, perhaps someone can explain what I was doing wrong?
For reference, I used a fresh installation of ubuntu. I executed the drush command with sudo. So I had all permissions. One or two other drush commands that were executed in the same fashion executed OK.
I used all standard methods to setup my test environment on localhost. Created a MySql user to configure database and provided all permissions to database, etc. This is not a show-stopper.
But perhaps someone can explain what I might have setup wrong?
Thanks.
Comment #6
Mac Clemmens commentedI'm experiencing the same problem. 127.0.0.1 works OK, but localhost does not.
Comment #8
hixster commentedI'm trying to use
drush generate-makefile myfile.makewhich fails due to the database connection issue mentioned here.I found this post via Google whilst looking for an answer.
We use MAMP for our local development and i've tried replacing localhost in my settings file with 127.0.0.1 but this breaks the site and doesn't solve the drush issue.
127.0.0.1 is the address I have set in my /etc/hosts file.
Can anyone suggest a solution?
**Update**
On closer inspection of the drush output , it seems to find the database, but the baseurl is wrong.
Comment #9
joestewart commentedhixster: It appears your command line php isn't the MAMP one that can connect to the mysql server ( php -i | grep -i mysql and or php --version) . There are a few ways around this. Here is an old post that explains it - http://raincitystudios.com/blogs-and-pods/steve-krueger/how-use-drush-lo...
Update: Oh, and this is an old closed issue. Better to create a new one and reference other pertinent issues.
Comment #10
hixster commentedHI Joe, will open another issue then - I tried linking to the MAMP PHP in the suggested article, but still experience the same issue.
I know the tutorial is old,as it goes on to mention linking to drush.php which I don't have - I do have drush added to my path so i'm not sure that step is necessary?
Comment #11
dhalbert commentedEven though this issue is closed, I would like to add a cautionary note, since it shows up close to the top in websearch results. I want to caution you a bit about changing "localhost" to "127.0.0.1" in your settings.php to get drush to run, and explain in more detail what is going on:
/var/lib/mysql/mysql.sock./var/lib/mysql/mysql.sock, and neither can drush:Use
drush -dto see what is going on:In fact, any attempt to use mysql with localhost will fail, not just via drush. For instance:
A better solution would be to be able to specify a different settings.php for use by drush, or be able to override the database connection settings. There are several drush issues floating around that seem to have patches to do something like that, and maybe it is even part of drush 5. I am a drush novice and am not sure.
Comment #12
bassplaya commentedI had the same issue and the change in the settings file to 127.0.0.1 did work for me as well but I have to say that my configuration was different. I had the following lines in my hosts file which I later commented out when I was using the 127.0.0.1 in my settings.php file:
127.0.0.1 www.sandboxd7
127.0.0.1 www.sandboxd6
and in my httpd.conf file living under /Applications/MAMP/conf/apache/httpd.conf I had:
NameVirtualHost www.sandboxd7
DocumentRoot "/Users/GraphicDesign/Sites/www.sandboxd7"
ServerName www.sandboxd7
NameVirtualHost www.sandboxd6
DocumentRoot "/Users/GraphicDesign/Sites/www.sandboxd6"
ServerName www.sandboxd6
I had done this to use multiple sites which are clearly living under: /Users/GraphicDesign/Sites/ so I could simply target the following url in my browser to work on one of my sites without changing the preferences in the MAMP preference pane all the time: http://www.sandboxd6 or http://www.sandboxd7
If anyone knows a way how I can still use my previous configuration for working on many sites at once using drush that would be just awesome.