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?
You can temporarily disable it at the session level.
SET SESSION sql_require_primary_key = 0;
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With