mysql_query() is NOT passing the command to the MySQL server using the C API
User Gerard H Pille gave me the correct tip - see the chat.

I had to remove the MYSQL_OPT_RECONNECT setting and now it works. The program runs now for more than 2 months without any issue1.

It were these 2 lines of code according to the MCVE:

bool autoReconnectMySQL = true;
mysql_options( mysqlConnection, MYSQL_OPT_RECONNECT, &amp;autoReconnectMySQL );


Why the setting is causing this issue I cannot answer.

New test results:
MySQL C API 8.0.11 doesn't have this issue anymore. 



1 Now, it runs for more than 1 year without any problem.