I made a backup of a Drupal9 site's database and tried to use it on another server.
I got the error:
#2006 - MySQL server has gone away
I thought that it was because of some file, query, or packet size limit, but no matter how much I compressed the database and how much I edited the server's parameters (such as "max_allowed_packet", etc).
Eventually I found out that it was none of that, but instead this part specifically:
ALTER TABLE `aza_node_revision__body`
ADD PRIMARY KEY (`entity_id`,`revision_id`,`deleted`,`delta`,`langcode`),
ADD KEY `bundle` (`bundle`),
ADD KEY `revision_id` (`revision_id`),
ADD KEY `body_format` (`body_format`);
Not knowing why this part failed, I tried dividing it into two:
ALTER TABLE `aza_node_revision__body`
ADD PRIMARY KEY (`entity_id`,`revision_id`,`deleted`,`delta`,`langcode`);
ALTER TABLE `aza_node_revision__body`
ADD KEY `bundle` (`bundle`),
ADD KEY `revision_id` (`revision_id`),
ADD KEY `body_format` (`body_format`);
Luckily, that worked, but I don't know why the server would disconnect when running this part of the query.