Tag Archive Delete

Byq292u

WordPress Database – Bulk Delete Users

Bulk Delete Users

I had 1000 spammer registrations from the same 2 domains.
Here’s how I got rid of them all, in seconds..

From the PLESK database “Web Admin”:

Delete the users..

delete FROM wp_users
WHERE user_email LIKE ‘%@domain.com’

** you could use ANY criteria here – I wanted rid of two specific groups of spammers..

Now-> Delete Orphaned Usermeta

** BACKUP YOUR DATABASE FIRST!

NB: you COULD try the “Bulk Delete Users” Plugin, but it tries to delete them one-by-one. On my shared hosting, it times out and is effectively useless, which is why I’m using SQL at the backend.

Please note: You should NEVER leave your tables with the default “wp_” prefix. Or have a user called “admin”, or a user with id=1. That’s just for start!
Let us secure your WordPress site for you:
http://www.q292u.com/services/secure-your-wordpress-site-our-new-fiverr-gig

Byq292u

WordPress Database – Delete Orphaned Posts

Delete Orphaned Posts

After manually using SQL to delete users, you can be left with (potentially a lot) of posts which now belong to users who simply don’t exist. You don’t want this, it wastes space and clogs things up.
There are two solutions to this:

  1. Delete the Orphaned Posts
  2. Assign them to another user.

I’m going to use option1, as I deleted those users for a reason – Spamming!

From PLESK or CPANEL database web admin:

Delete Orphaned Posts

DELETE
FROM `wp_posts`
WHERE post_author NOT
IN (
SELECT id
FROM wp_users
);

NONE of my tables have a wp_ prefix!

Now DELETE ORPHANED POSTMETA..

** BACKUP YOUR DATABASE FIRST!

Please note: You should NEVER leave your tables with the default “wp_” prefix. Or have a user called “admin”, or a user with id=1. That’s just for start!
Let us secure your WordPress site for you:
http://www.q292u.com/services/secure-your-wordpress-site-our-new-fiverr-gig

Byq292u

WordPress Database – Delete Orphaned Postmeta

Delete Orphaned Postmeta

After deleting posts using SQL, you will be left with (potentially a LOT) of orphaned postmeta records. You don’t want that! It wastes space and clogs up site performance. Get rid!

From PLESK or CPANEL database web admin:

DELETE
FROM wp_postmeta
WHERE post_id NOT
IN (
SELECT ID
FROM wp_posts
);

** BACKUP YOUR DATABASE FIRST!

Please note: You should NEVER leave your tables with the default “wp_” prefix. Or have a user called “admin”, or a user with id=1. That’s just for start!
Let us secure your WordPress site for you:
http://www.q292u.com/services/secure-your-wordpress-site-our-new-fiverr-gig

Byq292u

WordPress Database – Delete Orphaned Usermeta

Delete Orphaned Usermeta..

After using SQL to bulk-delete users, you’ll be left with (potentially a lot) of orphaned records in the “usermeta” table. You don’t want that. It’ll just waste space and clog things up.
After deleting 1000 user records, I had 20000 orphaned usermeta records – you get the picture..

From PLESK web admin, or similar:

delete FROM wp_usermeta WHERE user_id NOT IN (
SELECT ID
FROM wp_users
);

** BACK UP YOUR DATABASE FIRST!

Please note: You should NEVER leave your tables with the default “wp_” prefix. Or have a user called “admin”, or a user with id=1. That’s just for start!
Let us secure your WordPress site for you:
http://www.q292u.com/services/secure-your-wordpress-site-our-new-fiverr-gig