Question

Database cluster, how to change max_allowed_packet and max_execution_time?

I have a local MySQL dump that I want to migrate to my database cluster. Since the local MySQL is not available on the network I cant use the normal Migrate database functionality. Instead I want to import it as a dump/backup. However, I am encountering an issue where the query takes longer than 30 seconds or the packet is larger than 16 MB, causing the error Lost connection to MySQL server during query. This is a common problem for larger queries, and the usual solution is to increase the values of the max_allowed_packet and max_execution_time fields. I attempted to do this through the CLI, but I was informed that I need superadmin rights to make these changes. I also cannot find any settings on the dashboard that would resolve this issue.

How do you solve this problem here on DigitalOcean?


Submit an answer


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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
February 12, 2023

Hi there,

For the Managed Database clusters, you can’t directly make the changes, but instead, you would need to use the DigitalOcean API. You can find the documentation on how to make such config changes to your managed clusters here:

https://docs.digitalocean.com/reference/api/api-reference/#operation/databases_patch_config

Your request will look something like this:

curl -X PATCH \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  -d '{"config": {"max_allowed_packet": "67108864","sql_require_primary_key": true}}' \
  "https://api.digitalocean.com/v2/databases/9cc10173-e9ea-4176-9dbc-a4cee4c4ff30/config"

The max_execution_time is not configurable as far as I can see, but you can try also increasing the connect_timeout instead.

Let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.