Menu icon
RedCrackle
Menu icon
Services
01Design Transformation
About UsCase StudiesBlogContact Us

<

Blog post

How to fix drush's "Could not login with user ID #0" error

Neerav Mehta

Founder & CEO

On some projects, when I use drush, I get the error "Could not login with user ID #0". Drush also says that "This is typically caused by importing a MySQL database dump from a faulty tool which re-numbered the anonymous user ID in the users table.

See http://drupal.org/node/1029506 for help recovering from this situation." This error comes because uid = 0 got deleted in the "users" table. There are two ways to fix this problem.

Use user 1 instead of user 0

Simply use the option "-u 1" in the drush statement. So "drush cc all" will become "drush -u 1 cc all". With this argument, drush will load user 1 instead of user 0. This is a pretty easy quick-and-dirty workaround. You will have to use this argument every time you run drush.

Restore user 0 in the "users" table

This is a better and permanent fix. You can add user 0 to the "users" table. Execute the following MySQL query

  insert into users (name, pass, mail, theme, signature, language, init,
    timezone) values ('', '', '', '', '', '', '', '');
  update users set uid = 0 where name = '';

The first query inserts an empty row in the MySQL database. The second query sets the uid of the empty row to be 0. Now, when you execute any drush command, you should not get the error "Could not login with user ID #0".

Neerav Mehta

Neerav Mehta

Founder & CEO

Neerav Mehta is the Founder & CEO of Red Crackle. With sterling qualities, Neerav’s technological acumen is firing a generation of progressive companies on the digital path. With an undergraduate degree in Electrical Engineering from India's most prestigious institution IIT Bombay and having spent seven years developing and contributing to the launch of AMD's innovative line of computer products, Neerav founded Red Crackle where he is lauded for his dynamic and innovative genius.

View all posts

>

Read Next

10 Tips For Entrepreneurs In 2015

10 Tips For Entrepreneurs In 2015

Learn more

10 Ways To Increase Productivity At Work

10 Ways To Increase Productivity At Work

Learn more

30 best WordPress widgets for your site

30 best WordPress widgets for your site

Learn more

Let’s get you started!

Contact Us

>

RedCrackle

Explore

About Us

Services

Contact Us

Our address

5346 Gerine Blossom Dr,

San Jose, CA 95123

USA

Socials

Twitter
LinkedIn

© 2023 RedCrackle. All rights reserved.