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

stibynite’s picture

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

Shred’s picture

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

Anonymous’s picture

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.

Arkrep’s picture

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';
windsurf’s picture

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';
jmdlemos’s picture

I wan't to remove the administrator of my site, and change for another how can I do that?

Please help I will be very grateful!

kaps87’s picture

After applying some actions i couldn t log in as as Admin but only as the last user i entered.
Solved this through phpmyadmin.
steps: Database - Users- Delete the user (left only the admin user)
Refresh your page and delete any actions may caused this problem.

!!! I dont know if it would worked if there were more users registered. !!!

Hope this helped!