0

I read here that max allowed json in 1 GB.

Can we somehow change this default behaviour to reduce this MAX limit to few MBs or any other value in particular table column with json datatype?

Sahil Sharma
  • 3,847
  • 6
  • 48
  • 98

1 Answers1

0

As explained in Max JSON column length in MySQL, the maximum length of a JSON field is controlled by the max_paquet_size system variable.

As explained in the documentation https://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html, you can change this by adding

[mysqld]
max_allowed_packet=<xx>

in your my.ini or ~/.my.cnf file. Don't forget to restart the service !

Derlin
  • 9,572
  • 2
  • 32
  • 53
  • I want this to be reduced only for JSON datatype, not for all – Sahil Sharma Nov 02 '17 at 08:13
  • 1
    @maverick Derlin already explained what's possible. What do you *really want to do though*? If you want to *restrict* the size of Json documents in a single table, restricting the maximum size of the type is *not* a good solution. If the database doesn't allow you to specify a maximum *field* size, you'll have to find a different way to do this, eg with a trigger – Panagiotis Kanavos Nov 02 '17 at 08:45