"MySQL server has gone away" happened during update

Hello Matomo team and community.

I tried to update from 3.14.1 to 4.7.1 and got an error.
The number of MySQL connections was increased to the maximum, but an error occurred.
Is there any solution?

[2022-02-28 20:15:02.729]core:update --yes
.
.
.
[2022-03-01 20:33:18.578] Executing ./console plugin:uninstall “ExampleVisualization”… Done. [618 / 1164]
[2022-03-01 20:33:18.578] Executing php //piwik/console core:invalidate-report-data --sites=all --dates=2020-11-23,2022-02-23 --plugin=VisitFrequency… INFO [2022-03-01 20:33:17] 8185 Failed to schedule rearchiving of past reports for VisitFrequency plugin.
[2022-03-01 20:33:18.605] Done. [619 / 1164]
[2022-03-01 20:33:18.605] Executing …
[2022-03-01 20:33:18.605] [X] Critical Error during the update process:
[2022-03-01 20:33:18.605]
[2022-03-01 20:33:18.605] * //piwik/core/Updates/4.1.2-b1.php:
[2022-03-01 20:33:18.605] Error trying to execute the migration ‘’.
[2022-03-01 20:33:18.605] The error was: Mysqli prepare error: MySQL server has gone away
[2022-03-01 20:33:18.605]
[2022-03-01 20:33:18.605] The above is the core error message. It should help explain the cause, but if you require further help please:
[2022-03-01 20:33:18.605]
[2022-03-01 20:33:18.605] * Check the [ Matomo FAQ ] which explains most common errors during update.
[2022-03-01 20:33:18.605] * Ask your system administrator - they may be able to help you with the error which is most likely related to your server or MySQL setup.
[2022-03-01 20:33:18.605]
[2022-03-01 20:33:18.605] If you are an advanced user and encounter an error in the database upgrade:
[2022-03-01 20:33:18.605]
[2022-03-01 20:33:18.605] * identify and correct the source of the problem (e.g., memory_limit or max_execution_time)
[2022-03-01 20:33:18.605] * execute the remaining queries in the update that failed
[2022-03-01 20:33:18.605] * manually update the option table in your Matomo database, setting the value of version_core to the version of the failed update
[2022-03-01 20:33:18.618] * re-run the updater (through the browser or command-line) to continue with the remaining updates
[2022-03-01 20:33:18.618] * report the problem (and solution) so that Matomo can be improved
[2022-03-01 20:33:18.618] ERROR [2022-03-02 11:33:17] 8185 Uncaught exception: /***/piwik/plugins/CoreUpdater/Commands/Update.php(267): Matomo could not be updated! See above for more information. [Query: , CLI mode: 1]
[2022-03-02 12:21:50.958]

引用

Can you maybe rollback and update step by step?
Check also in the https://matomo.org/changelog/ if there is no major update that could conflict with your server configuration…