Report this

What is the reason for this report?

How to disable SQL_REQUIRE_PRIMARY_KEY in digital ocean manged database for mysql?

Posted on September 14, 2021

How to disable SQL_REQUIRE_PRIMARY_KEY in digital ocean manged database for mysql globaly?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @ajaypatel,

You can reach out to DO support to disable global sql_require_primary_key for your MySQL managed database.

If you need to disable it on session level, you can execute the below command.

SET SESSION sql_require_primary_key = 0;

I hope this helps!

Regards, Rajkishore

Hi,

Our engineer team has updated API documentation to make database configuration changes via API; you will now be able to disable sql_require_primary_key using API.

To check database configuration check the below link: https://docs.digitalocean.com/reference/api/api-reference/#operation/get_database_config

To update database configuration check the below link: https://docs.digitalocean.com/reference/api/api-reference/#operation/patch_database_config ​​​​​​​

To create “$DIGITALOCEAN_TOKEN” check the below link: https://docs.digitalocean.com/reference/api/create-personal-access-token/ ​​​​​​​

To fetch “$database_cluster_uuid” check the below link: https://docs.digitalocean.com/reference/api/api-reference/#operation/list_database_clusters

You can reach out to support if you are seeing any errors while changing database configuration using API https://docs.digitalocean.com/support/

I hope this helps!

Regards, Rajkishore

Hi there,

In addition to what has already been mentioned, one option here is to use the doctl CLI.

So, to disable sql_require_primary_key in your DigitalOcean Managed MySQL database, using the doctl CLI you can run the following command:

doctl databases configuration update <database-cluster-id> --config-json '{"sql_require_primary_key": false}' --engine mysql

Replace <database-cluster-id> with your actual database cluster ID.

This command updates the database configuration to set sql_require_primary_key to false.

For more details, refer to the doctl databases configuration update documentation

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.