Community Documentation

Deleted first user account?

Last updated July 12, 2009. Created by LeeHunter on October 24, 2007.
Edited by markus_petrux, VM, bekasu, sepeck. Log in to edit this page.

If, by accident, you happen to delete the original "Administrator" account/user, you will need to recreate it.

INSERT INTO users (uid, name, pass) VALUES ('1', 'yourname', md5('yourpassword'));

you can also try and work with the methods below:

UID1 is the 'super admin' account.

- create a new account with user name and password of your choice : this account will initially be a regular user account, to be turned into an "Administrator" account following the next step.
- go to database table "users" and change the UID of this new account to "1" - You may now login to this account as the super admin account.

if you use phpmyadmin for MySql database administration, this should only take a few seconds to fix.

user_register not enabled

The above only works if the "user_register" variable is *not* set to s:1:"0";.

UPDATE variable SET value = 's:1:"1";' WHERE name = 'user_register';
DELETE FROM cache WHERE cid = 'variables';

This will change your site so that you can follow the above instructions.

Prevent account cancellation for uid 1

For Drupal 5 and 6, you may want to check out the Protect Critical Users module.

For Drupal 7, this issue will be probably solved by then. See: #46149: Prevent account cancellation for uid 1

Comments

this worked for me

INSERT INTO users (uid, name, pass, status) VALUES ('1', 'yourname', md5('yourpassword'), '1');

Help with Admin account

Hello everyone,

I was deleting some Users that were Spamming my site and I inadvertently deleted my Admin account. Through searching the
Drupal forums I stumbled across a solution to login to PHPMyAdmin and change the user. I believe I did everything correctly,
however, when I go back to login to the site, I get a pending admin approval message. I'm really frustrated and can't believe
that I did this. The funny thing is that right before I did this, I changed the user settings to require Admin approval for all users.

Any help would be appreciated.

Paul

The first comment on here

The first comment on here sould work as it sets the status to 1 which gives that user "approval" through the SQL. If you do not have access to sql command then i dont know.

User account is Blocked or not Active

I used the MySQL command in the article which doesn't activate the account. you can use this command to update the account so it's active.

UPDATE users SET status = '1' where uid = '1';

worked for me

The above suggestions were a big help.

INSERT INTO users (uid, name, pass) VALUES ('1', 'yourname', md5('yourpassword'));

then

UPDATE users SET status = '1' where uid = '1';

worked for me.

This recommendation was not necessary:

UPDATE variable SET value = 's:1:"1";' WHERE name = 'user_register';
DELETE FROM cache WHERE cid = 'variables';

About this page

Drupal version
Drupal 5.x, Drupal 6.x
Audience
Site administrators

Reference

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.