First, make sure you have set max_allowed_packet in the appropriate section [mysqldump] of the config file my.cnf and that it does not exceed the maximal value of 1G:
Or you can also specify it at runtime (without having to change my.cnf):
mysqldump --max-allowed-packet=1G ...
Dump based backups (logical backups) and recommended for small-medium databases, however, you could speed up logical backup by using enhanced logical backup tools like mysqlpump or mydumper.
Raw backups are recommended for large databases and there are two major tools to explore: mysqlbackup (Enterprise backup) and Percona xtrabackup (free - only Linux ...
Looks like there has been a bug on the issue:
----- 2019-07-22 8.0.17 General Availability -- -- -----
mysqldump failed to wrap SET NAMES utf8mb4 and SET character_set_client = utf8mb4 statements within version-specific comments, which could cause compatibility problems. (Bug #29007506, Bug #93450)
----- 2018-11-20 MariaDB 10.3.11 -- Release Note -- -----
I have checked out mysql-5.4.46, and searched client/mysqldump.c for "SET character_set_client".
[:~/Source/mysql-server/client]↥ 9c3a49ec84b* ± grep 'SET character_set_client' mysqldump.c
"/*!50003 SET character_set_client = %s */ %s\n"
"/*!50003 SET character_set_client = @saved_cs_client */ %s\n"
I had a 500 MB SQL file to import. It took me around 2 hours. The mysqld CPU usage was next to 100 % at the start of the import process. But after a few minutes the CPU usage was down to 15 %.
I tried many tweaks but only this one helped me: innodb_flush_log_at_trx_commit = 0
After applying this setting and restarting mysql the import took just 3 minutes! ...