Disable / enable WordPress comments from phpMyAdmin

WordPress comments option is often not needed for our website. It is also true that we often forget to disable the commenting option. As a result – spammers fillup your website with garbage/spam comments to create backlinks of their website. You can always disable the commenting option from the wordpress admin dashboard. But assume you are a web hosting provider and you found one of your client’s WordPress site is quickly filling up with spam comments. You may not have wordpress admin password of your client’s website. In this case you can quickly disable comment option by using a small query in phpMyAdmin panel.

You need to follow the following steps:

1. Go to the phpMyAdmin panel from your hosting control panel.

2. Locate the wordpress database in the drop down list in the left panel and click on it.

3. Now click on the “SQL” tab in the navigation panel in the right page.

4. Within the “Run SQL Query” box, paste the following code:

UPDATE wp_posts p SET comment_status = ‘closed’, ping_status = ‘closed’ WHERE comment_status = ‘open’;

(Replace “wp_post” with the appropriate prefix of the wordpress table)
If successful, you should have disabled the ability to comment on your posts across your entire blog. To re-enable the commenting run the following SQL query the same way you ran the comment disable query:

UPDATE wp_posts p SET comment_status = ‘open’, ping_status = ‘open’ WHERE comment_status = ‘closed’;

(Replace “wp_post” with the appropriate prefix of the wordpress table)