Página 1 de 1
Tamanho da sentença(SQL) no MySQL
Enviado: 06 Mar 2025 18:46
por Itamar M. Lins Jr.
Olá!
Qual é o tamanho máximo da STRING->sentença em Mysql ?
Saudações,
Itamar M. Lins Jr.
Tamanho da sentença(SQL) no MySQL
Enviado: 06 Mar 2025 18:49
por JoséQuintas
max_allowed_packed
O default começou em 4MB, mas em versões mais novas pode ser 16MB.
Pode ser aumentado até 2GB se não me engano.
Isso também afeta o limite pra salvar binários, imagens, etc.
Por exemplo: salvo o EXE em base64.
insert into .... value 'xxxxx'
Se o default for 4MB, não vou poder salvar EXE com mais de 3MB (base64 fica maior)
Tamanho da sentença(SQL) no MySQL
Enviado: 06 Mar 2025 18:52
por JoséQuintas
Uso isto
Código: Selecionar todos
BEGIN SEQUENCE WITH __BreakBlock()
:Execute( "SELECT @@global.max_allowed_packet AS QTD" )
IF :Number( "QTD" ) < 16000000
Errorsys_WriteErrorLog( ;
"Max Allowed Packet=" + NumberSQL( :Number( "QTD" ) ) + hb_Eol() + ;
"Alterar seção [mysqld] em my.ini no servidor" + hb_Eol() + ;
"max_allowed_packet=32M", 2 )
cnSQL:Execute( "SET @@global.max_allowed_packet=" + NumberSQL( 16 * 1024 * 1024 ) )
ENDIF
ENDSEQUENCE
O novo valor fica até que o servidor seja reiniciado.
Aí coloquei pra registrar como erro, pra me lembrar aonde preciso mexer em servidor.
VALE PRA TODOS OS TERMINAIS, não apenas aonde foi executado o comando.
Dá pra ir quebrando o galho assim.
No máximo vai ser uma vez por dia, aonde desliga servidor.
Tamanho da sentença(SQL) no MySQL
Enviado: 06 Mar 2025 19:21
por alxsts
Olá!
MySQL 8.4 Reference Manual / ... / Packet Too Large
⁹
B.3.2.8 Packet Too Large
A communication packet is a single SQL statement sent to the MySQL server, a single row that is sent to the client, or a binary log event sent from a replication source server to a replica.
The largest possible packet that can be transmitted to or from a MySQL 8.4 server or client is 1GB.
When a MySQL client or the mysqld server receives a packet bigger than max_allowed_packet bytes, it issues an ER_NET_PACKET_TOO_LARGE error and closes the connection. With some clients, you may also get a Lost connection to MySQL server during query error if the communication packet is too large.
Both the client and the server have their own max_allowed_packet variable, so if you want to handle big packets, you must increase this variable both in the client and in the server.
If you are using the mysql client program, its default max_allowed_packet variable is 16MB. To set a larger value, start mysql like this:
That sets the packet size to 32MB.
The server's default max_allowed_packet value is 64MB. You can increase this if the server needs to handle big queries (for example, if you are working with big BLOB columns). For example, to set the variable to 128MB, start the server like this:
You can also use an option file to set max_allowed_packet. For example, to set the size for the server to 128MB, add the following lines in an option file:
It is safe to increase the value of this variable because the extra memory is allocated only when needed. For example, mysqld allocates more memory only when you issue a long query or when mysqld must return a large result row. The small default value of the variable is a precaution to catch incorrect packets between the client and server and also to ensure that you do not run out of memory by using large packets accidentally.
You can also get strange problems with large packets if you are using large BLOB values but have not given mysqld access to enough memory to handle the query. If you suspect this is the case, try adding ulimit -d 256000 to the beginning of the mysqld_safe script and restarting mysqld.
https://dev.mysql.com/doc/refman/8.4/en/packet-too-large.html
Tamanho da sentença(SQL) no MySQL
Enviado: 07 Mar 2025 10:06
por Itamar M. Lins Jr.
Olá!
Em SQLMIX.

- Captura de tela 2025-03-07 100707.png (10.33 KiB) Exibido 2430 vezes
Código: Selecionar todos
dbUseArea( , , "SELECT @@global.max_allowed_packet AS nMA",'ma' )
hwg_msginfo('Max_allowed_packet: ' + hb_ntos(nMA))
FechaDb('ma')
Lembrando que nMA é um field do DBF VIRTUAL. Fechou o DBF, a variável->(virtual do virtual rsrs) deixa de existir.
Tive que subir para 20MB por conta do wordpress.(penso que é isso), fiz para o outro programador, front-end(php).
Saudações,
Itamar M. Lins Jr.