Closed (fixed)
Project:
Drush
Version:
All-versions-4.x-dev
Component:
Miscellaneous
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
6 Jul 2009 at 17:41 UTC
Updated:
13 Jun 2015 at 18:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
sittard commentedGot the same error message as well! I've blocked anonymous user access to my site. Using the command
drush -u 1 statusworks for me. The -u option specifies a user id to log in with.Comment #2
moshe weitzman commentedComment #3
shrop commentedThis tip also worked for me on a site where I was receiving the same message. I am cool if it is by design, but am curious as to what permissions trigger Drush to not be able to login as the anonymous user. Most of my sites are multisites so I am also using --uri=http://www.example.com in my Drush command strings.
Comment #4
sheldon rampton commentedI'm also getting this error message when I run drush to install modules using drush.php dl admin_menu. The download seems to work, despite the error message. When I add the -u 1 option, the "Could not login" error message disappears, and instead I get "Notice: Trying to get property of non-object in /mysitepath/includes/common.inc on line 1797."
I guess this isn't stopping me from getting work done, but it's confusing, and when I get an error message like this, I'd like to know what it means.
Comment #5
okokokok commentedI'm trying to work with a profile from themesnap (www.themesnap.com/premium-drupal-themes/magazine-plus.html - it's a darn shame the CSS is not GPL).
Now I'm trying to use Drush on a site I've set up with this theme, but I'm getting:
And I'm curious about ways that would allow me to use Drush on this site.
Comment #6
okokokok commenteddrush -u 1 statusis working now, just like most other drush stuff,drush -u 1 infois not.It could be nice to have the user ID in the configuration somewhere.
Comment #7
mrfelton commenteddrush -u 1 status does get me the status, but I also get the following error at the end:
An error occurred at function : drush_core_statusComment #8
fenstratJust a note for anyone else who comes across this based on the anon user error, i.e.
Could not login with user ID #0.It means exactly what it says so check the user table and ensure there is a user with uid 0.
In my case there was no uid 0 due to a restored faulty backup (where the first entry in the user table, i.e. the anon user, was allocated a uid which was not 0).
Comment #9
rsvelko commentedThanks to #8 I did export import of the missing row and voala:
(The SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; ensures that the uid will be = 0 and not the last_uid + 1).
Correct the PREFIX before executing.
This stopped the drush errors.
Comment #10
citronica commentedThanks for this. Oddly enough, I had this problem on a fresh install in which I'd never monkeyed with the database at all. For no obvious reason, there was no uid 0 -- the anonymous user was uid 3 (?). I just changed it in the database to 0 and the drush error is now gone.
Comment #11
sutharsan commentedI get this error because the site I work on uses a settings.php in
/sites/example.comand has no settings.php in/sites/default. Using-l http://localhost/example.comdoes not help either. Only the-u 1gets me through without errors.Comment #12
jwilson3This will happen if you reload a site from a dumpfile created by
drush sql-dump; the uid of UserZero (the anonymous user) can get set to 1+number of users.Assuming you're using drush you can do the following to fix it (YMMV):
NOTE: your mileage may vary, update the stuff in between the back-ticks if you need to specify something else (eg --uri=example.com) to get to the correct mysql connection string.
Comment #13
protoplasm commentedMy 1+number of users occurred without the sql-dump on migrating the database. But the same concept in #12 worked for me. I just edited the UID of that entry directly to 0 and everything was normal again. You have to give drush props for the clue to the problem via the error message.
Comment #14
jghyde commentedCombo of #9 first & then #12 worked for me. Excellent!
Joe
http://www.hydeinteractive.com/
Comment #15
roball commentedAdding
to "drushrc.php" residing in drush's install dir solves all these weird problems.
Comment #16
sivaji_ganesh_jojodae commentedIn recent version drushrc.php is no longer available instead you need to change includes/environment.inc line 902
$drush_user = drush_set_context('DRUSH_USER', drush_get_option(array('u', 'user'), 0));to
$drush_user = drush_set_context('DRUSH_USER', drush_get_option(array('u', 'user'), 1));Comment #17
roball commentedThe shipped file is called "example.drushrc.php" and it *is* there in both versions 3.3 (v 1.8 2010/06/05) and 4.0-rc1 (v 1.13 2010/12/05). Why should it have been removed?
Comment #18
pog21 commentedThanks #8 for a clear explanation. I had this problem upon installing with fantastico. Used phpmyadmin to look at users table, which showed an entry right before user 1 with blank fields, but id of 3. Manually changed this to 0 and now it's working.
Comment #19
webchickThis patch might help reduce duplicate support requests about this. I was stranded and had no idea what was causing this until I googled.
Feel free to mark it back to "by design," though. Not sure how much special casing you really want to put into Drush for a 6.x-era bug caused by faulty database dumping tools.
Comment #20
webchickComment #21
moshe weitzman commentedcomitted. thanks.
Comment #23
chx commentedThis is a weak solution. Ask the user "Do you want to fix this?". Here's how: name and mail both are unique and so if there is a user whose name and mail are empty that's the anon user, run UPDATE uid = uid - uid WHERE name = '' AND mail = '' and hope for the best
Comment #24
roball commentedWhy not just defaulting $options['u'] to '1'?
Comment #25
moshe weitzman commentedI'm fine leaving it as docs only.
Comment #26
wizonesolutionsThanks #8! Worked for me.
Comment #27
EvanDonovan commentedHere is the insert SQL that you want for 7.x:
Comment #28
hectorplus commented#27, work for me, running Drupal 7.x
Thanks