I deleted the admin account and cant log in. Which file do I need to enter admin info manually?

Thnaks

Comments

VM’s picture

your going to have to manually put one back in the database. I believe.

dirkca’s picture

Thank you...will try.

Also, you answered my questions befoe, thank you.

If you dont mind here is one more:

The confirmation emails are super slow...I am talking several hours. Any ideas why?

Thanks

VM’s picture

have you set up the emails properly in administer -> settings -> users ?

mail delays arent really drupal issues. could be your mail server (hosts mail server).

in reference to the admin account. you could also set up a new drupal with a new database, inspect this new one for the way the admin account is created, and replicate this in the old DB.

this post should help http://drupal.org/node/100137#comment-175834

nazneen-1’s picture

What do you mean by put one back in database?How to do this?
Because I accidently deleted my admin account.

VM’s picture

install a fresh copy drupal on your local machine or a test site, inspect the way the superadmin is set up default and duplicate this in live database for a user you have control of.

cog.rusty’s picture

If you are brave you can try this as well: Go to your database and browse the 'users' table to make sure that your #1 account is missing (that there is no row with uid=1). If it is really missing, then create it with an SQL query like:

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

(Use your table name prefix (if any) and your username, password and email.)
When you log in go to user/1 and fill-in any other missing details.

awhite251’s picture

i did so but it says im not activated or blocked!

fixed it i changed status to 1 in database, thx for the sql injection!

jocrenalix’s picture

I accidentally deleted user 1 as I was attempting remove Google Adsense ID. What I did was create new account, then logged on my phpmyadmin from Cpanel, then changed the user ID of the new account i created to USER 1. That solved the problem. I was able to log back as administrator.

annalina614’s picture

What do you mean by Go to your database and browse the users table?
I'm using Filezilla, is this where I would look?
Or does it have something to do with my host?

cog.rusty’s picture

Not Filezilla. On most hosts you can use a tool called phpMyAdmin to work with your database. Check for a phpMyAdmin link in your host's cpanel or ask your host.

The SQL statement that I gave for creating user 1 again is missing one required value, "status". It should be:

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

This works to re-add user #1, but when I create a blog post it says posted by anonymous and the link shows up as " 's blog " and goes to /blog/0

Any idea how to fix this? I can reset the associations with the sql statement submitted by someone else above, but Drupal thinks all new posts are by user 0, a non-existent user. Any ideas?

cog.rusty’s picture

User 0 is the "anonymous" user account.

One way for this to happen is to allow anonymous users to create blog posts (in admin/user/permissions) and then to post while you are not logged in.

plato1123’s picture

Hmmmm, but I am logged in, as user #1, the admin. Any node I create of any content type comes up as being posted by anonymous and links back to user 0, not user 1.

Anonymous’s picture

Thanks a lot. This command created a user, but again was showing same error, user/password not found. Later i found a comment about tried with new browser. Hence I tried with IE 8 and requested for new password by giving username. I got the password reset link in mail and could reset password. Earlier I was using mozilla firefox.

All this happened when tried to upgrade from D7.4 to D7.7. after update.php admin user name and password was not accepting.Checked in phpmyadmin and found no row was present in user.

once again thanks for helping to create user, site http://vision4life.in is working ok now.

VM’s picture

it wouldn't have worked in D7 since D7 password storage is totally different than pre which is what this thread was about. Note it's marked Drupal 4.7.x

Be very careful to read which version threads are for. Using the wrong snippet directly on the DB can break your site.

rowanprice’s picture

Worked for me on phpMyAdmin and Drupal 6.20

KhoiNqq’s picture

Just create new account, update your database set uid of that account to 1.

Antikx’s picture

Thanks. You saved my butt.
I used to laugh at people that did this.... then I did it. *blush*
Goes to show I shouldn't judge people. :)

sergiu-bivol’s picture

Your post helped me too. And also a lot of greetings to Zach Harkey , who's post was the right thing in the right place for me!

tml605’s picture

it really helped.

annalina614’s picture

How do I update my database set uid?

atzi’s picture

Thanks,
I created a new account then changed it to #1 in phpMyAdmin, database, `drup_users`
but then had to select MD5 on password.

mbirkland’s picture

I did the same thing. Strange but it seems to be easy to do. I was only trying to delete the user icon and it's tempting to hit delete instead of submit at the bottom of the user account page. My solution was to restore (import) the database from a previous phpmyadmin export. Worked like a charm. (a good sale for backing up your database which is easy with phpmyadmin). I attempted a few of the solutions posted for establishing admin rights to other users in the database, but my version of mysql was obviously different.

All other things considered Drupal 5.0 beta has been great (newbee from wordpress) look forward to the final.
http://birkland.dyndns.org

shawnpetriw’s picture

Exact same scenario. Boy was I surprised! It was so easy! There really needs to be a "Really delete you're ENTIRE account" warning message.

chirale’s picture

Same story, I want to delete my user picture and I deleted the account. Fortunately, it happens in a local test installation. It mustn't be so easy, there are fixed field weight for title and body in nodes (try to change them) but the administrator account isn't protected? Really freaky.

Zach Harkey’s picture

One problem with deleting the admin user (or any user) is that all nodes created by that user are now owned by Anonymous (uid: 0). This can be a real big problem if you had a lot of nodes.

If you know you don't have any nodes created by 'Anonymous' you could run this line of SQL on your database (in phpmyadmin or command line) to change them all back:

UPDATE node SET uid = '1' WHERE uid = '0';

To restore rightful ownership of comments you will have to do something like this (replace Your Name with the exact name you were using before the deletion):

UPDATE comments SET uid='1' WHERE name = 'Your Name';

Depending on how you have set things up, that may be the best route to go for restoring the ownership of your nodes too, so instead of what I put above you might try (though I did not test this):

UPDATE node SET uid='1' WHERE name = 'Your Name';

-zach
--
harkey design

: z

LWVMD’s picture

If User1 was the manager of any organic groups, then those groups get Anonymous as their manager(s).

VM’s picture

another reason that the first created user should only be used to admin a site and not be used as a "standard" user.

P D Waghela’s picture

I deleted the admin account, but retrived it using sql. i also set the node uid as 1 from uid 0. and then was able see the pages, but now if i want to visit the website as a simple user, it says "Page not Found". could you please help me...or any body please...Thanks in advance.

VM’s picture

by altering UID 0 you've removed the anon user UID. A better idea is to create a NEW user and alter that users UID to 1.

darrelf’s picture

Thanks for posting this information. It prevented my morning from turning very sour :)

razzuk’s picture

I'm currently experiencing the same problem as most of you have solved, I've tried all the fixes in the thread to no avail. It would appear I don't have the privileges on my mysql user. I can't edit the UID of a user (via PHPmyadmin) because I simply get an access denied error. My main problem now is the fact I have no idea of how I should go about granting myself the privileges I should already have. It would be greatly appreciated if one of you more knowledgeable people could point me in the right direction. If it helps, my host is Fasthosts, perhaps they have a weird way of handling these privileges. Any help would save me alot of bother. Thanks.

peaceninja’s picture

you could try to update the mysql database from php...using whatever sql-connect credentials you originally gave to your drupal install. It sounds primarily a hosting problem though

aterchin’s picture

I did something similar. deleted the admin account. had a copy of my database handy. opened up a new phpmyadmin window, brought up edit screen for the copy, showing 'user 1'. with another window open of phpmyadmin, now in the current db user table, went to the Insert page and just copied the info back and forth, then inserted it. presto.

Then i couldnt remember my password, when i tried to log in. so i just coped the password from a test user which i knew was 'test' in the same way.

squarecandy’s picture

Thanks for the SQL solution. Really turned my frown upside down!

I too was shocked at how easy it was to (accidentally) delete user 1 from the user 1 account...

Anyways, thanks for getting me back on track quickly.

kelizabeth’s picture

I have the exact same issue. I went to delete the userpic in my admin account and somehow deleted the user. Now I when I go to my site I recieve the following message:

Site off-line

The site is currently not available due to technical problems. Please try again later. Thank you for your understanding.

If you are the maintainer of this site, please check your database settings in the settings.php file and ensure that your hosting provider's database server is running. For more help, see the handbook, or contact your hosting provider.

The mysqli error was: Access denied for user 'ber0914603060783'@'97.74.144.126' (using password: YES).

I did what others have done and logged into the database and changed the userid of another (testuser) to 1, but nothing has changed. Help! I was planning to launch this site TOMORROW!

Thanks.

cog.rusty’s picture

This is not the same error. Your error message says that Drupal can't connect to the database at all. This has nothing to do with Drupal user accounts.

Make sure that the database username, database password, database name and database server are correct in the $db_url line in your settings.php file.

kelizabeth’s picture

Yup, figured it out. I (stupidly) changed the database password because I couldn't remember it when I was trying to login to make changes to the user I wanted as a new admin. I changed the password in the string in system.php in the drupal files, and all is happy and working again. :)

VM’s picture

I believe you mean settings.php?

nicl’s picture

I just did this - was mass deleting some user accounts. Stupid of me I know but it seems as if I am hardly the only one. It really doesn't make sense for Drupal to allow you to delete the only admin account! This in my mind is a bug/something which should be changed.

VM’s picture

drupal.org/project/protect_critical_users

jedihe’s picture

protect_critical_users looks very nice. I'm gonna roll a small site with it enabled to avoid a semi-admin user to delete the admin account :)

jedihe

holeepassion’s picture

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

works a charm .. same issues and all my nodes were gone but got it working again .... but i cannot login still for some reasons ?

VM’s picture

if you are sure 'yourpassword' is correct

clear all cache and cookies from browser
clear/empty/truncate the sessions table in the DB

test

kunal1983’s picture

Sorry, i am very new in drupal and I need to know the name of table responsible for administrator credentials in any drupal database
So, can any oe help me please?

VM’s picture

the user table. UID 1 = first created user.

P D Waghela’s picture

dirkca if you have the solution for this please make me know, i have tried all the update and insert options of data base and could not access the admin. please give me a right solution.
Thanks in advance...

VM’s picture

The thread is 6 years old and filed against Drupal 4.7.x.

Which version of Drupal are you using? as if not, 4.7.x then the changes mentioned in the thread won't work since the DB has changed a great deal since then.

can also use drush : http://drupal.org/project/drush

P D Waghela’s picture

i deleted the admin account, then by sql query i got it back. but now i cant access any of my node...It says the page not found...please give me the solution. as i am new to drupal.

fmilland’s picture

Thanks a lot, this happened to me and I was scared as hell, really saved my butt!