I have got thousands of junk entries in my Drupal 6 website. Is there a way I can Delete all nodes from database accept from user1 and admin.

I also want to delete all users accept user1 and admin.


Yes, you could do that with


It will delete the nodes and users progressively using the Batch API.

  • Create a content / node based View
  • Add the bulk operations field
  • Configure bulk operations field to add "Delete item'
  • Add filters to View to exclude content from user1 / admin
  • Run the View, check to select all rows, and bulk delete the relevant nodes.

Repeat using a user-based View to delete users.

Note, prior to deleting users, check the account cancellation settings at Admin > Configuration > Account settings > Registration and cancellation

| improve this answer | |
  • Thanks for the quick reply. I have though run this on phpMyadmin delete from nodes where uid not in (1,3) but this also removes the uid 0 which I think is for anonymous users. can we recreate uid 0 – Fahad Ur Rehman Feb 7 '13 at 21:54
  • 2
    I'd advise you to use VBO instead otherwise too much risk of broken / orphaned data in the db (i.e your current situation) For now, recreate anon user with: insert into users (name, pass, mail, theme, signature, language, init, timezone) values ('', '', '', '', '', '', '', ''); update users set uid = 0 where name = ''; and then use VBO – David Thomas Feb 7 '13 at 21:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.