update recommendation modificar max_allowed_packet cambiar mysql

modificar - mysql max_allowed_packet recommendation



Cómo cambiar el tamaño de max_allowed_packet (11)

Cambie el my.ini o ~/.my.cnf incluyendo la línea única en la sección [mysqld] en su archivo:

max_allowed_packet=500M

a continuación, reinicie el servicio MySQL y ya está.

Consulte la documentation para más información.

Tengo un problema con los campos BLOB en mi base de datos MySQL: cuando subo archivos con un tamaño superior a aproximadamente 1 MB, recibo un error Packets larger than max_allowed_packet are not allowed.

Esto es lo que he intentado:

En MySQL Query Browser ejecuté una show variables like ''max_allowed_packet'' que me dio 1048576.

Luego ejecuto el set global max_allowed_packet=33554432 consultas set global max_allowed_packet=33554432 seguido de show variables like ''max_allowed_packet'' - me da 33554432 como se esperaba.

Pero cuando reinicio el servidor MySQL, mágicamente vuelve a 1048576. ¿Qué estoy haciendo mal aquí?

Pregunta extra, ¿es posible comprimir un campo BLOB?


Creo que algunos también querrán saber cómo encontrar el archivo my.ini en su PC. Para los usuarios de Windows, creo que la mejor manera es la siguiente:

  1. Win + R (acceso directo para ''ejecutar''), escriba services.msc , Enter
  2. Puede encontrar una entrada como ''MySQL56'', hacer clic derecho en ella, seleccionar propiedades
  3. Podría ver algo como "D: / Archivos de programa / MySQL / MySQL Server 5.6 / bin / mysqld" --defaults-file = "D: / ProgramData / MySQL / MySQL Server 5.6 / my.ini" MySQL56

Obtuve esta respuesta de http://bugs.mysql.com/bug.php?id=68516


Este error se debe a que sus datos contienen un valor mayor que el establecido.

Simplemente escriba el max_allowed_packed=500M o puede calcular ese 500 * 1024k y usarlo en lugar de 500M si lo desea.

Ahora simplemente reinicie MySQL.


La variable max_allowed_packet se puede configurar globalmente ejecutando una consulta.

Sin embargo, si no lo cambias en el archivo my.ini (como sugirió dragon112), el valor se restablecerá cuando se reinicie el servidor, incluso si lo configuras globalmente.

Para cambiar el paquete máximo permitido para todos a 1 GB hasta que el servidor se reinicie:

SET GLOBAL max_allowed_packet=1073741824;


Muchos de los que respondieron vieron el problema y ya dieron la solución.

Solo quiero sugerir otra solución, que está cambiando el valor de la variable Glogal desde la herramienta Mysql Workbench . Por supuesto, si utiliza Workbench ejecutándose localmente en el servidor (o mediante una conexión SSH)

Simplemente te conectas a tu instancia y accedes al menú:

Servidor -> Archivo de opciones -> Redes -> max_allowed_packed

Establece el valor deseado y luego necesita reiniciar el servicio MySql .


Para cualquier persona que ejecute MySQL en el servicio Amazon RDS, este cambio se realiza a través de grupos de parámetros . Debe crear una nueva PG o usar una existente (que no sea la predeterminada, que es de solo lectura).

Debes buscar el parámetro max_allowed_packet , cambiar su valor y luego presionar guardar.

De vuelta en su instancia de MySQL, si creó un nuevo PG, debe adjuntar el PG a su instancia (es posible que necesite un reinicio). Si cambió un PG que ya estaba adjunto a su instancia, los cambios se aplicarán sin reiniciar, a todas sus instancias que tengan ese PG adjunto.


Si quieres subir imágenes de gran tamaño o datos en base de datos. Simplemente cambie el tipo de datos a ''BIG BLOB'' .


Si se max_allowed_packet este error al realizar una copia de seguridad, max_allowed_packet se puede configurar en my.cnf particularmente para mysqldump .

[mysqldump] max_allowed_packet=512M

Seguí recibiendo este error mientras realizaba un mysqldump y no lo entendí porque tenía este conjunto en my.cnf en la sección [mysqld] . Una vez que me di cuenta de que podía configurarlo para [mysqldump] y establecer el valor, mis copias de seguridad se completaron sin problemas.


Siguiendo todas las instrucciones, esto es lo que hice y trabajé:

mysql> SELECT CONNECTION_ID();//This is my ID for this session. +-----------------+ | CONNECTION_ID() | +-----------------+ | 20 | +-----------------+ 1 row in set (0.00 sec) mysql> select @max_allowed_packet //Mysql do not found @max_allowed_packet +---------------------+ | @max_allowed_packet | +---------------------+ | NULL | +---------------------+ 1 row in set (0.00 sec) mysql> Select @@global.max_allowed_packet; //That is better... I have max_allowed_packet=32M inside my.ini +-----------------------------+ | @@global.max_allowed_packet | +-----------------------------+ | 33554432 | +-----------------------------+ 1 row in set (0.00 sec) mysql> **SET GLOBAL max_allowed_packet=1073741824**; //Now I''m changing the value. Query OK, 0 rows affected (0.00 sec) mysql> select @max_allowed_packet; //Mysql not found @max_allowed_packet +---------------------+ | @max_allowed_packet | +---------------------+ | NULL | +---------------------+ 1 row in set (0.00 sec) mysql> Select @@global.max_allowed_packet;//The new value. And I still have max_allowed_packet=32M inisde my.ini +-----------------------------+ | @@global.max_allowed_packet | +-----------------------------+ | 1073741824 | +-----------------------------+ 1 row in set (0.00 sec)

Entonces, como podemos ver, el paquete max_allowed_packet se ha cambiado fuera de my.ini.

Vamos a dejar la sesión y volver a comprobar:

mysql> exit Bye C:/Windows/System32>mysql -uroot -pPassword Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 21 Server version: 5.6.26-log MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ''help;'' or ''/h'' for help. Type ''/c'' to clear the current input statement. mysql> SELECT CONNECTION_ID();//This is my ID for this session. +-----------------+ | CONNECTION_ID() | +-----------------+ | 21 | +-----------------+ 1 row in set (0.00 sec) mysql> Select @@global.max_allowed_packet;//The new value still here and And I still have max_allowed_packet=32M inisde my.ini +-----------------------------+ | @@global.max_allowed_packet | +-----------------------------+ | 1073741824 | +-----------------------------+ 1 row in set (0.00 sec) Now I will stop the server 2016-02-03 10:28:30 - Server is stopped mysql> SELECT CONNECTION_ID(); ERROR 2013 (HY000): Lost connection to MySQL server during query Now I will start the server 2016-02-03 10:31:54 - Server is running C:/Windows/System32>mysql -uroot -pPassword Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 9 Server version: 5.6.26-log MySQL Community Server (GPL) Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ''help;'' or ''/h'' for help. Type ''/c'' to clear the current input statement. mysql> SELECT CONNECTION_ID(); +-----------------+ | CONNECTION_ID() | +-----------------+ | 9 | +-----------------+ 1 row in set (0.00 sec) mysql> Select @@global.max_allowed_packet;//The previous new value has gone. Now I see what I have inside my.ini again. +-----------------------------+ | @@global.max_allowed_packet | +-----------------------------+ | 33554432 | +-----------------------------+ 1 row in set (0.00 sec)

Conclusión, después de SET GLOBAL max_allowed_packet = 1073741824, el servidor tendrá el nuevo max_allowed_packet hasta que se reinicie, como alguien dijo anteriormente.


Uno de mis desarrolladores junior tenía problemas para modificar esto, así que pensé que lo ampliaría con más detalle para los usuarios de Linux:

1) terminal abierta

2) ssh root @ YOURIP

3) introduzca la contraseña de root

4) nano /etc/mysql/my.cnf (si no se reconoce el comando, haga esto primero o intente vi y luego repita: yum instale nano)

5) agregue la línea: max_allowed_packet = 256M (obviamente ajuste el tamaño para lo que necesite) en la sección [MYSQLD]. Cometió el error de ponerlo primero en la parte inferior del archivo, por lo que no funcionó.

6) Control + O (guardar) luego ENTER (confirmar) luego Control + X (salir del archivo)

7) servicio mysqld reinicio

8) Puede verificar el cambio en la sección de variables en phpmyadmin


Para aquellos que ejecutan wamp mysql server

Ícono de bandeja de Wamp -> MySql -> my.ini

[wampmysqld] port = 3306 socket = /tmp/mysql.sock key_buffer_size = 16M max_allowed_packet = 16M // --> changing this wont solve sort_buffer_size = 512K

Desplácese hasta el final hasta que encuentre

[mysqld] port=3306 explicit_defaults_for_timestamp = TRUE

Añadir la línea de packet_size entre

[mysqld] port=3306 max_allowed_packet = 16M explicit_defaults_for_timestamp = TRUE

Compruebe si funcionó con esta consulta

Select @@global.max_allowed_packet;