Title: WordPress database error Multiple primary key defined for query
Last modified: January 24, 2021

---

# WordPress database error Multiple primary key defined for query

 *  Resolved [Steve](https://wordpress.org/support/users/steveatty/)
 * (@steveatty)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined-for-query/)
 * I’m seeing this error in my php error logs :
 * [24-Jan-2021 22:50:48 UTC] WordPress database error Multiple primary key defined
   for query ALTER TABLE blogs_2_ewwwio_queue CHANGE COLUMN `id` id int(14) unsigned
   NOT NULL AUTO_INCREMENT PRIMARY KEY made by do_action(‘admin_init’), WP_Hook-
   >do_action, WP_Hook->apply_filters, ewww_image_optimizer_admin_init, ewww_image_optimizer_upgrade,
   ewww_image_optimizer_install_table, dbDelta
 * I’m on version 6.00

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * (@nosilver4u)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined-for-query/#post-13955203)
 * There should not be another primary key, so you’ll want to take a look at the
   existing indices on the ewwwio_queue table and remove any primary keys that aren’t
   on the ID column.
 *  Thread Starter [Steve](https://wordpress.org/support/users/steveatty/)
 * (@steveatty)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined-for-query/#post-13955484)
 * I think I’ve found it.
 * I’m running MySQL 8.0.22
 * Display width specification for integer data types was deprecated in MySQL 8.0.17
 * So I think what is happening is that the WordPress dbDelta is picking up that
   ID has no width set compared to the table definition in your code, and tries 
   to set it. But as the column already has an index on it the alter code fails.
 *  Plugin Author [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * (@nosilver4u)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined-for-query/#post-13955529)
 * Hmm, that’s possible, as I haven’t run EWWW IO on a MySQL 8 server. I’m a bit
   surprised no one else has reported the issue previously, but I’ll test it out
   and see if I can replicate it.
    I suspect the fix is to simply remove the display
   widths, but I’ll have to test and see if that causes any issues.
 *  Plugin Author [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * (@nosilver4u)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined-for-query/#post-13962138)
 * Yup, you were right on! Installed on a clean server with 8.0.22, then changed
   version to trigger upgrade routine, and it threw errors on both tables.
    I removed
   the display widths, increased the version, and no errors, hurrah! Also tested
   on my dev server with Maria 10.5 and no errors there either, so I’ll include 
   this in the next release.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘WordPress database error Multiple primary key defined for query’ is closed
to new replies.

 * ![](https://ps.w.org/ewww-image-optimizer/assets/icon-256x256.png?rev=1582276)
 * [EWWW Image Optimizer](https://wordpress.org/plugins/ewww-image-optimizer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ewww-image-optimizer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ewww-image-optimizer/)
 * [Active Topics](https://wordpress.org/support/plugin/ewww-image-optimizer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ewww-image-optimizer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ewww-image-optimizer/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Shane Bishop](https://wordpress.org/support/users/nosilver4u/)
 * Last activity: [5 years, 4 months ago](https://wordpress.org/support/topic/wordpress-database-error-multiple-primary-key-defined-for-query/#post-13962138)
 * Status: resolved