I have a Digital Ocean-managed MySQL database. In order to prevent data replication issues across nodes, DO automatically sets your instance with sql_require_primary_key
. This is fine in theory except that there are various WordPress plugins, including notably WP Cerber, which do not support that setting.
I can ask Digital Ocean to disable the setting for me, but I run the risk of my data not replicating properly. So what I’m wondering is, is there a way to disable that setting for specific databases and even tables, or is that setting restricted to the connection settings and the server-wide settings?
2
Answers
The first table on the page you referred is created like this:
Adding a primary key:
You can use any name for the field
primaryKey
, as long as it is not an existing field.This should not interfere with the plugin. And if it does than you should probably not (want) to use that plugin at all.
You can temporarily disable it at the session level.
I have some migration code that makes primary keys after it makes the table. I added the above snippet to the migration before the table is created. In the end it does make a primary key so all is well.