Max allowed packet (MySQL): verschil tussen versies

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
Regel 60: Regel 60:
 
</pre>
 
</pre>
  
=== Aanpassing my.cnf ===
+
=== Aanpassing ===
  
 
Aanpassing in /etc/mysql/my.cnf voor systeemwijde aanpassing:
 
Aanpassing in /etc/mysql/my.cnf voor systeemwijde aanpassing:

Versie van 29 okt 2020 12:34

[1]:

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 master replication server to a slave.

The largest possible packet that can be transmitted to or from a MySQL 8.0 server or client is 1GB = 2^30 = 1.073.741.824

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.

Actuele waardes uitlezen

Je kunt de waarde van max_allowed_packet uitlezen middels bv.:

show variables where variable_name like "max_a%";

+--------------------+----------+
| Variable_name      | Value    |
+--------------------+----------+
| max_allowed_packet | 67108864 |
+--------------------+----------+
1 row in set (0.00 sec)

Waarschijnlijk is de waarde gegeven in bytes, omdat het geen afgerond getal is en het sommetje verbazend goed uitkomt:

* 67108864/1024    = 65.536 KB
* 67108864/1024^2  = 64 MB

De maximale waarde is 1GB:

* 1 GB = 2^10 MB = 1024^1 KB =         1.024 MB
*      = 2^20 KB = 1024^2 KB =     1.048.576 KB
*      = 2^30  B = 1024^3  B = 1.073.741.824 B

Het probleem is echter, dat server, client en mysqldump hun eigen versie hebben van deze parameter. Ik weet niet welke versie bovenstaand commando geeft.

Storing mysqldump (Juni 2020)

Oh oh:

mysqldump example_com > example_com-20200611.sql
mysqldump: Error 2020: Got packet bigger than 'max_allowed_packet' bytes when dumping table `wp_options` at row: 1929

LET OP: Dit is een storing in mysqldump! Niet in de server of de mysql-client! Deze entiteiten hebben alledrie hun eigen max_allowed_packet-max. waardes

On-the-fly

Dit werkte, en is een goede manier om eea. te checken:

mysqldump --max_allowed_packet=1024MB example_com > example_com.sql

Aanpassing

Aanpassing in /etc/mysql/my.cnf voor systeemwijde aanpassing:

###########################################################################
# Strompf - [mysqldump]
###########################################################################
#
[mysqldump]
max_allowed_packet=1024MB

Gevolgd door sudo service mysql restart om het direct te actueren.

Zie ook

Bronnen