This video tutorial is to show you, a #WordPress website owner or manager: how you can remove #usersspam with email addresses ending in a specific spam domain from your WordPress database using #phpMyAdmin and SQL queries.
Note: In our case, we will start by removing spam users who are registered using the @tyypet.cn emails.
For your convenience, please use this file as it already contains commands prepared for you: https://pastebin.com/jWsY6Z3w
Step 1: Backup Your Database
Before making any changes, create a complete backup of your database to avoid accidental data loss.
--
Step 2: Open phpMyAdmin
Log in to your StackCP dashboard, go to the section "MySQL Databases" and log into your database. Once in - select your WordPress database from the list on the left.
--
Step 3: Find Users by most used domains in their emails
SELECT
SUBSTRING_INDEX(user_email, '@', -1) AS domain,
COUNT(*) AS count
FROM
wp_users
WHERE
SUBSTRING_INDEX(user_email, '@', -1) NOT IN ('gmail.com', 'outlook.com', 'hotmail.com')
GROUP BY
domain
ORDER BY
count DESC
LIMIT 100;
--
Step 4: Check These Users (just in a case):
SELECT * FROM `wp_users` WHERE `user_email` LIKE '%@tyypet.cn';
--
Step 5: Remove Users
DELETE FROM `wp_users` WHERE `user_email` LIKE '%@tyypet.cn';
--
Step 6: Cleanup Metadata
DELETE FROM `wp_usermeta` WHERE `user_id` NOT IN (SELECT `ID` FROM `wp_users`);
--
Step 7 (not mentioned in the tutorial): Update WordPress Cache
If your site uses caching plugins or object caching, clear the cache to ensure changes are reflected.
I hope, you find this helpful.
Best wishes,
Helmuts
HostMaria.com