'MySQL VARBINARY with maximum size

I can't set varbinary with maximum size in MySql 8.0
Show this error message :
Could not set value

Please write correct syntax.
Thanks.



Solution 1:[1]

In MySQL, one can't use 'max' as length like SQL Server. If you want a column with max size binary data, then LONGBLOB is a better option.

https://dev.mysql.com/doc/refman/5.5/en/blob.html

Solution 2:[2]

setting VARBINARY(65535) will throw an error in mysql if you have other columns

Query error: #1118 - Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. This includes storage overhead, check the manual. You have to change some columns to TEXT or BLOBs

in my case setting it to varbinary(65450) was successful because I have 11 more columns to consider.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Gauravsa
Solution 2 Kym NT