Skip to content

Force Primary Key Requirement

Thomas Shone edited this page Jul 7, 2024 · 7 revisions

Issue Type

Operational

Problem

You are running MySQL 8.0.13+ (changelog) without the sql_require_primary_key variable enabled.

Every table must have a Primary Key, so it's better to enforce this at the database level.

Remediation

You can either change the variable at runtime

SET GLOBAL sql_require_primary_key=ON

Or you can change the variable at startup by modifying your my.cnf configuration

[mysqld]
sql_require_primary_key=ON

External Resources