You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WordPress 4.9.5启用Simple Error Log插件触发主键重复数据库错误

Fixing "Duplicate entry '0' for key 'PRIMARY'" Error with Simple Error Log on WordPress 4.9.5

Hey there, let's tackle this database error you're seeing after enabling the Simple Error Log plugin on WordPress 4.9.5. I've run into similar issues with older WP versions and plugins that mishandle custom post type entries, so here's a step-by-step breakdown of how to fix it:

What's Causing This?

The error WordPress database error Duplicate entry '0' for key 'PRIMARY' means the plugin is trying to insert a row into the wp_posts table with an ID value of 0—but the ID column is the primary key, which is supposed to be auto-incrementing and unique. WordPress expects the database to generate a new unique ID automatically for new posts (including plugin-generated log entries), so the plugin is incorrectly forcing an ID of 0 here.

Step 1: Verify the Plugin is the Culprit

First, let's confirm the error stops when the plugin is disabled:

  • Access your site via FTP or cPanel File Manager.
  • Navigate to wp-content/plugins/.
  • Rename the simple-error-log folder to something like simple-error-log-disabled.
  • Refresh your WordPress admin panel—if the error disappears, you've confirmed the plugin is the source.

Step 2: Fix the wp_posts Table Structure

It's possible your wp_posts table's primary key isn't set to auto-increment properly. Here's how to fix that:

  • Log into your hosting control panel and open phpMyAdmin.
  • Select your WordPress database from the left sidebar.
  • Find the wp_posts table (replace wp_ with your database prefix if you changed it).
  • Click the "Structure" tab.
  • Look for the ID column: it should be set to INT(11) UNSIGNED NOT NULL AUTO_INCREMENT and marked as the primary key.
  • If not, click the "Change" link next to the ID column, check the "AUTO_INCREMENT" box, and save the changes.

Step 3: Remove the Duplicate ID Entry (If Exists)

If there's already a row in wp_posts with ID = 0, we need to delete it first:

  • In phpMyAdmin, select your database and click the "SQL" tab.
  • Run this query (replace wp_ with your prefix):
    DELETE FROM wp_posts WHERE ID = 0;
    
  • Click "Go" to execute the query.

Step 4: Update or Replace the Plugin

Since WordPress 4.9.5 is an older version, the Simple Error Log plugin might not be compatible with it:

  • If the plugin is still maintained, check for an updated version that supports WP 4.9.5 and install it.
  • If it's no longer maintained, switch to an alternative error logging plugin (like Error Log Monitor) that's compatible with your WP version.

Important Notes

  • Always back up your database before making any changes—this way you can restore it if something goes wrong.
  • If you're not comfortable working with phpMyAdmin or database queries, reach out to a developer or your hosting support for help.

内容的提问来源于stack exchange,提问作者Nilesh Bhanse

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.25 06:20:01