{"id":2399,"date":"2026-08-03T19:22:34","date_gmt":"2026-08-03T23:22:34","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2012\/10\/10\/320-wordpress-comment-spam\/"},"modified":"2026-08-03T19:24:56","modified_gmt":"2026-08-03T23:24:56","slug":"remove-wordpress-spam-comments-phpmyadmin","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/","title":{"rendered":"Clean Up WordPress Comment Spam with phpMyAdmin"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Bulk-deleting spam from the WordPress Comments screen fails once you are dealing with tens of thousands of rows. This guide covers the SQL approach: which queries to run, how to find spam the filter missed, and the two cleanup steps most tutorials leave out.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The fastest cleanup is one query:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">DELETE<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">FROM<\/span><span style=\"color: #E1E4E8\"> wp_comments <\/span><span style=\"color: #F97583\">WHERE<\/span><span style=\"color: #E1E4E8\"> comment_approved <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;spam&#39;<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">That clears everything Akismet or your moderation queue already flagged. Spam that slipped through needs targeted searching, and once the rows are gone you still have two problems to fix: orphaned metadata in <code>wp_commentmeta<\/code>, and post comment counts that no longer match the database.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Important Warnings Before You Begin<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">There is no undo in SQL. Three things first:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Export the database.<\/strong> Use the phpMyAdmin <strong>Export<\/strong> tab with the Quick method and SQL format, or cPanel&#8217;s Backup Wizard for very large databases.<\/li>\n\n\n\n<li><strong>Verify your table prefix.<\/strong> Examples here use <code>wp_<\/code>. Check the <code>$table_prefix<\/code> line in <code>wp-config.php<\/code>, which also lists your database name under <code>DB_NAME<\/code>.<\/li>\n\n\n\n<li><strong>Run a SELECT first.<\/strong> Every DELETE below has a matching SELECT. Run that, review what comes back, then swap in the DELETE.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For a few hundred comments, the admin <strong>Comments &gt; Spam &gt; Empty Spam<\/strong> button is enough. It starts failing in the low thousands, when the request exceeds <code>max_execution_time<\/code> or <code>memory_limit<\/code> and dies without deleting anything. That is the point where phpMyAdmin earns its place.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Which Tables and Statuses Control WordPress Comments?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Two tables matter. <code>wp_comments<\/code> holds the comments. <code>wp_commentmeta<\/code> holds metadata attached to them, which is where anti-spam plugins write their scoring data.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The columns you will filter on are <code>comment_post_ID<\/code>, <code>comment_author<\/code>, <code>comment_author_email<\/code>, <code>comment_author_url<\/code>, <code>comment_author_IP<\/code>, <code>comment_content<\/code>, and <code>comment_approved<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That last one does the heavy lifting. It is a varchar column, not a boolean, and it holds five values set through <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_set_comment_status\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\"><code>wp_set_comment_status()<\/code><\/a> and <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_trash_post_comments\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\"><code>wp_trash_post_comments()<\/code><\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-table is-style-stripes\"><table><thead><tr><th>Value<\/th><th>Meaning<\/th><th>Safe to bulk-delete<\/th><\/tr><\/thead><tbody><tr><td><code>1<\/code><\/td><td>Approved and live<\/td><td>No<\/td><\/tr><tr><td><code>0<\/code><\/td><td>Pending moderation<\/td><td>No<\/td><\/tr><tr><td><code>spam<\/code><\/td><td>Flagged as spam<\/td><td>Yes<\/td><\/tr><tr><td><code>trash<\/code><\/td><td>Trashed<\/td><td>Yes<\/td><\/tr><tr><td><code>post-trashed<\/code><\/td><td>Parent post is trashed<\/td><td>Only with the post<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Status <code>0<\/code> catches a lot of people out. It is the moderation queue, not a spam bucket, so deleting it removes legitimate comments waiting on your approval.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How To Delete Every Comment Already Marked as Spam<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Check the volume first:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">SELECT<\/span><span style=\"color: #E1E4E8\"> comment_approved, <\/span><span style=\"color: #79B8FF\">COUNT<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">) <\/span><span style=\"color: #F97583\">AS<\/span><span style=\"color: #E1E4E8\"> total<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">FROM<\/span><span style=\"color: #E1E4E8\"> wp_comments<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">GROUP BY<\/span><span style=\"color: #E1E4E8\"> comment_approved;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Then clear the two safe statuses:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">DELETE<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">FROM<\/span><span style=\"color: #E1E4E8\"> wp_comments <\/span><span style=\"color: #F97583\">WHERE<\/span><span style=\"color: #E1E4E8\"> comment_approved <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;spam&#39;<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">DELETE<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">FROM<\/span><span style=\"color: #E1E4E8\"> wp_comments <\/span><span style=\"color: #F97583\">WHERE<\/span><span style=\"color: #E1E4E8\"> comment_approved <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;trash&#39;<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">On a site that has been collecting spam for years, this alone can remove a six-figure row count.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How To Find Spam the Filter Never Flagged<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Approved spam is the harder problem. It sits live on your posts with a plausible name and a link in the website field.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">SELECT<\/span><span style=\"color: #E1E4E8\"> comment_ID, comment_author, comment_author_url, comment_content<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">FROM<\/span><span style=\"color: #E1E4E8\"> wp_comments<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">WHERE<\/span><span style=\"color: #E1E4E8\"> comment_author <\/span><span style=\"color: #F97583\">LIKE<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;%payday%&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">   <\/span><span style=\"color: #F97583\">OR<\/span><span style=\"color: #E1E4E8\"> comment_author_url <\/span><span style=\"color: #F97583\">LIKE<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;%bit.ly%&#39;<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>%<\/code> character matches any sequence, so this catches both &#8220;payday loans&#8221; and &#8220;quick payday.&#8221; Review the results, then rerun with <code>DELETE FROM wp_comments WHERE<\/code> and the same conditions. The website field is usually more productive than the name, and <code>comment_author_IP<\/code> works the same way for a single abusive source.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">phpMyAdmin&#8217;s <strong>Search<\/strong> tab does this through a form if you prefer clicking. The SQL is worth learning anyway, since the <a href=\"https:\/\/www.inmotionhosting.com\/support\/server\/databases\/manage-databases-cpanel-phpmyadmin\/\">phpMyAdmin interface<\/a> changes between releases while the queries do not.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How To Spot Repeat Spammers With a Grouping Query<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Bots reuse identities, so grouping surfaces them without you guessing keywords:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">SELECT<\/span><span style=\"color: #E1E4E8\"> comment_author, comment_author_email, <\/span><span style=\"color: #79B8FF\">COUNT<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">) <\/span><span style=\"color: #F97583\">AS<\/span><span style=\"color: #E1E4E8\"> total<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">FROM<\/span><span style=\"color: #E1E4E8\"> wp_comments<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">GROUP BY<\/span><span style=\"color: #E1E4E8\"> comment_author, comment_author_email<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">HAVING<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">COUNT<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">) <\/span><span style=\"color: #F97583\">&gt;<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">5<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">ORDER BY<\/span><span style=\"color: #E1E4E8\"> total <\/span><span style=\"color: #F97583\">DESC<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Note that <code>&gt; 5<\/code> returns authors with six or more. Use <code>&gt;= 5<\/code> if you want five and up. Grouping on name and email together separates a genuine repeat commenter from a bot cycling through addresses. Swap in <code>comment_author_IP<\/code> or <code>comment_post_ID<\/code> to find a single source or a single post under attack, then check <code>comment_content<\/code> before deleting anything.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Does wp_commentmeta Need Cleaning Too?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Deleting from <code>wp_comments<\/code> does not touch <code>wp_commentmeta<\/code>. Anti-spam plugins write a row every time they evaluate a comment, and those rows survive the parent comment. On heavily spammed sites the meta table often ends up larger than the comments table.<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">DELETE<\/span><span style=\"color: #E1E4E8\"> cm <\/span><span style=\"color: #F97583\">FROM<\/span><span style=\"color: #E1E4E8\"> wp_commentmeta cm<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">LEFT JOIN<\/span><span style=\"color: #E1E4E8\"> wp_comments c <\/span><span style=\"color: #F97583\">ON<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">c<\/span><span style=\"color: #E1E4E8\">.<\/span><span style=\"color: #79B8FF\">comment_ID<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">cm<\/span><span style=\"color: #E1E4E8\">.<\/span><span style=\"color: #79B8FF\">comment_id<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">WHERE<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">c<\/span><span style=\"color: #E1E4E8\">.<\/span><span style=\"color: #79B8FF\">comment_ID<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">IS<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">NULL<\/span><span style=\"color: #E1E4E8\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The JOIN form performs better than a <code>NOT IN<\/code> subquery on large tables. We cover this in more depth in <a href=\"\/support\/edu\/wordpress\/cleaning-up-old-comment-meta-data-in-wordpress\/\">cleaning up old comment meta data in WordPress<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Deleted rows do not release disk space on their own. <code>OPTIMIZE TABLE wp_comments, wp_commentmeta;<\/code> reclaims it, but <a href=\"https:\/\/dev.mysql.com\/doc\/refman\/8.0\/en\/optimize-table.html\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">MySQL maps this to a full table rebuild on InnoDB<\/a>, so run it during low traffic.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Are Comment Counts Wrong After the Cleanup?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">WordPress caches an approved comment total in the <code>comment_count<\/code> column of <code>wp_posts<\/code>. <a href=\"https:\/\/developer.wordpress.org\/reference\/functions\/wp_update_comment_count_now\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\"><code>wp_update_comment_count_now()<\/code><\/a> recalculates it by counting rows where <code>comment_approved = '1'<\/code>, and direct SQL bypasses that function.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This only matters if you deleted approved comments. Removing <code>spam<\/code> or <code>trash<\/code> rows leaves the count untouched. If yours are off:<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono-NL.ttf\" style=\"font-size:clamp(16px, 1rem, 24px);font-family:Code-Pro-JetBrains-Mono-NL,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:clamp(26px, 1.625rem, 39px);--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">UPDATE<\/span><span style=\"color: #E1E4E8\"> wp_posts p<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">SET<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">p<\/span><span style=\"color: #E1E4E8\">.<\/span><span style=\"color: #79B8FF\">comment_count<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> (<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">  <\/span><span style=\"color: #F97583\">SELECT<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">COUNT<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">) <\/span><span style=\"color: #F97583\">FROM<\/span><span style=\"color: #E1E4E8\"> wp_comments c<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">  <\/span><span style=\"color: #F97583\">WHERE<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">c<\/span><span style=\"color: #E1E4E8\">.<\/span><span style=\"color: #79B8FF\">comment_post_ID<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">p<\/span><span style=\"color: #E1E4E8\">.<\/span><span style=\"color: #79B8FF\">ID<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">AND<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">c<\/span><span style=\"color: #E1E4E8\">.<\/span><span style=\"color: #79B8FF\">comment_approved<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;1&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">);<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">WP-CLI has a purpose-built equivalent, <a href=\"https:\/\/developer.wordpress.org\/cli\/commands\/comment\/recount\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\"><code>wp comment recount<\/code><\/a>. If the site runs Redis or Memcached, flush the object cache afterward or the admin will keep serving stale counts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How To Keep Spam From Filling the Table Again<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Under <strong>Settings &gt; Discussion<\/strong>, require manual approval or a previously approved comment, enable automatic comment closing on posts older than 30 days, and add recurring spam terms to <strong>Disallowed Comment Keys<\/strong>. Keep an anti-spam plugin active so new spam lands in the <code>spam<\/code> status instead of going live.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Bots posting directly to <code>wp-comments-post.php<\/code> also consume CPU on every attempt. If that traffic is pushing your account against its resource limits, <a href=\"\/vps-hosting\/wordpress\">VPS Hosting for WordPress<\/a> gives you dedicated CPU, memory, and root access for firewall-level filtering. Contact <a href=\"\/contact\">our 24\/7 support team<\/a> if exports time out or you are unsure which database belongs to which site.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary of Recommended Workflow<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Export the database<\/strong> and confirm the file downloaded.<\/li>\n\n\n\n<li><strong>Verify the table prefix<\/strong> in <code>wp-config.php<\/code>.<\/li>\n\n\n\n<li><strong>Audit statuses<\/strong> with the <code>GROUP BY comment_approved<\/code> query.<\/li>\n\n\n\n<li><strong>Delete <code>spam<\/code> and <code>trash<\/code> rows.<\/strong> Leave status <code>0<\/code> alone.<\/li>\n\n\n\n<li><strong>Search for unflagged spam<\/strong> with <code>LIKE<\/code> patterns, running the <code>SELECT<\/code> before the <code>DELETE<\/code>.<\/li>\n\n\n\n<li><strong>Group by author and email<\/strong> to catch repeat offenders, verifying content first.<\/li>\n\n\n\n<li><strong>Clear orphaned <code>wp_commentmeta<\/code><\/strong> with the <code>LEFT JOIN<\/code> delete.<\/li>\n\n\n\n<li><strong>Resync <code>comment_count<\/code><\/strong> only if you deleted approved comments.<\/li>\n\n\n\n<li><strong>Run <code>OPTIMIZE TABLE<\/code><\/strong> during low traffic, then flush the object cache if you use one.<\/li>\n\n\n\n<li><strong>Tighten Settings > Discussion<\/strong> so you are not repeating this next quarter.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Bulk-deleting spam from the WordPress Comments screen fails once you are dealing with tens of thousands of rows. This guide covers the SQL approach: which queries to run, how to find spam the filter missed, and the two cleanup steps most tutorials leave out. The fastest cleanup is one query: That clears everything Akismet or<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/\"> Read More ><\/a><\/p>\n","protected":false},"author":56983,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_ayudawp_aiss_exclude":false,"_ayudawp_aiss_summary":"For a few hundred comments, the admin Comments &gt; Spam &gt; Empty Spam button is enough. Anti-spam plugins write a row every time they evaluate a comment, and those rows survive the parent comment. Under Settings &gt; Discussion, require manual approval or a previously approved comment, enable automatic comment closing on posts older than 30 days, and add recurring spam terms to Disallowed Comment Keys.","_ayudawp_aiss_summary_provider":"extractive","_ayudawp_aiss_summary_hash":"0da390a82e3d199bc0de5358925643a3229314d9","_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[56],"tags":[],"class_list":["post-2399","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to Remove WordPress Spam Comments in phpMyAdmin<\/title>\n<meta name=\"description\" content=\"Delete WordPress spam comments in bulk with phpMyAdmin. Learn the SQL queries, how to clear orphaned comment meta, and how to fix broken comment counts.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Remove WordPress Spam Comments in phpMyAdmin\" \/>\n<meta property=\"og:description\" content=\"Delete WordPress spam comments in bulk with phpMyAdmin. Learn the SQL queries, how to clear orphaned comment meta, and how to fix broken comment counts.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-03T23:22:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-08-03T23:24:56+00:00\" \/>\n<meta name=\"author\" content=\"Carrie Smaha\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@carriesmaha\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Carrie Smaha\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/\"},\"author\":{\"name\":\"Carrie Smaha\",\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#\\\/schema\\\/person\\\/595948dab2995d347a87076abdae19d8\"},\"headline\":\"Clean Up WordPress Comment Spam with phpMyAdmin\",\"datePublished\":\"2026-08-03T23:22:34+00:00\",\"dateModified\":\"2026-08-03T23:24:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/\"},\"wordCount\":913,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#organization\"},\"articleSection\":[\"WordPress Tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/\",\"url\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/\",\"name\":\"How to Remove WordPress Spam Comments in phpMyAdmin\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#website\"},\"datePublished\":\"2026-08-03T23:22:34+00:00\",\"dateModified\":\"2026-08-03T23:24:56+00:00\",\"description\":\"Delete WordPress spam comments in bulk with phpMyAdmin. Learn the SQL queries, how to clear orphaned comment meta, and how to fix broken comment counts.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/edu\\\/wordpress\\\/remove-wordpress-spam-comments-phpmyadmin\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Clean Up WordPress Comment Spam with phpMyAdmin\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/wp-content\\\/uploads\\\/2023\\\/02\\\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/inmotionhosting\\\/\",\"https:\\\/\\\/x.com\\\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/#\\\/schema\\\/person\\\/595948dab2995d347a87076abdae19d8\",\"name\":\"Carrie Smaha\",\"description\":\"Carrie Smaha is a digital strategy, web development, and SEO leader with 20 years of experience. She built her foundation in fast-paced agency environments before moving in-house to InMotion Hosting, where she leads go-to-market programs, agency initiatives, and technical product marketing that connects product capability to real customer decisions.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/carriesmaha\\\/\",\"https:\\\/\\\/x.com\\\/carriesmaha\"],\"url\":\"https:\\\/\\\/www.inmotionhosting.com\\\/support\\\/author\\\/carries\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Remove WordPress Spam Comments in phpMyAdmin","description":"Delete WordPress spam comments in bulk with phpMyAdmin. Learn the SQL queries, how to clear orphaned comment meta, and how to fix broken comment counts.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/","og_locale":"en_US","og_type":"article","og_title":"How to Remove WordPress Spam Comments in phpMyAdmin","og_description":"Delete WordPress spam comments in bulk with phpMyAdmin. Learn the SQL queries, how to clear orphaned comment meta, and how to fix broken comment counts.","og_url":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2026-08-03T23:22:34+00:00","article_modified_time":"2026-08-03T23:24:56+00:00","author":"Carrie Smaha","twitter_card":"summary_large_image","twitter_creator":"@carriesmaha","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"Carrie Smaha","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/"},"author":{"name":"Carrie Smaha","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/595948dab2995d347a87076abdae19d8"},"headline":"Clean Up WordPress Comment Spam with phpMyAdmin","datePublished":"2026-08-03T23:22:34+00:00","dateModified":"2026-08-03T23:24:56+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/"},"wordCount":913,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["WordPress Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/","url":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/","name":"How to Remove WordPress Spam Comments in phpMyAdmin","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2026-08-03T23:22:34+00:00","dateModified":"2026-08-03T23:24:56+00:00","description":"Delete WordPress spam comments in bulk with phpMyAdmin. Learn the SQL queries, how to clear orphaned comment meta, and how to fix broken comment counts.","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/remove-wordpress-spam-comments-phpmyadmin\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"Clean Up WordPress Comment Spam with phpMyAdmin"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/595948dab2995d347a87076abdae19d8","name":"Carrie Smaha","description":"Carrie Smaha is a digital strategy, web development, and SEO leader with 20 years of experience. She built her foundation in fast-paced agency environments before moving in-house to InMotion Hosting, where she leads go-to-market programs, agency initiatives, and technical product marketing that connects product capability to real customer decisions.","sameAs":["https:\/\/www.linkedin.com\/in\/carriesmaha\/","https:\/\/x.com\/carriesmaha"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/carries\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":{"id":56,"name":"WordPress Tutorials","slug":"wordpress","link":"https:\/\/www.inmotionhosting.com\/support\/edu\/wordpress\/"},"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/2399","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/56983"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=2399"}],"version-history":[{"count":5,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/2399\/revisions"}],"predecessor-version":[{"id":900250,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/2399\/revisions\/900250"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=2399"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=2399"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=2399"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}