159

What is maximum query size for mysql? Some times the server stops working when I fire a too long query.

2

2 Answers 2

228

You can check your current server setting with:

SHOW VARIABLES LIKE 'max_allowed_packet';

This gives you the answer in bytes. for e.g max_allowed_packet=1048576 or 1 MiB

2
  • If it's in bytes, then the 1mb from answer is about 8 times smaller. Oct 5, 2017 at 10:36
  • 7
    It seems that this answer implies that the maximum query length is only limited by the maximum packet size that can be sent to the server. This basically means that there is no upper limit to query lengths as long as you're able to send it to the server.
    – jlh
    Apr 6, 2018 at 9:03
39

To increase the max_allowed_packet, open

my.ini/my.cnf under [mysqld] section.

Once the change is done you would have to restart the server.

1
  • 3
    Using "128MB", "1GB", etc is allowed. The value does not have to be in bytes (but it is supported). Max value is 1GB. If you set it to more than 1GB, mysql will still start normally, but it will not accept anything over 1GB. Nov 22, 2021 at 8:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.