Many standard Arduino boards (e.g. Uno, Mega, Nano, Pro Mini) will reset whenever you open Serial Monitor so that could be why the problem seems to be resolved after you open Serial Monitor.
ElPaso:
MySQL_Cursor *cur_mem = new MySQL_Cursor(&conn);
// Execute the query
cur_mem->execute(query);
// Note: since there are no results, we do not need to read any data
// Deleting the cursor also frees up memory used
delete cur_mem;
Use of dynamic memory allocation in the resource constrained environment of a microcontroller is generally a very bad idea. There are certain very specific conditions under which it can be done safely. I can't say whether that is the case here or not but certainly when you start getting strange behavior after some time that would make me suspicious.
A tool I have found useful for diagnosing the cause of code hanging is this library:
This library is only compatible with AVR microcontrollers (Uno, Mega, Leonardo, etc.).
Note that you should not use the watchdog timer on Pro Mini or old Nanos unless you have replaced their buggy bootloader which is not compatible with watchdog resets.
Note that the maximum watchdog timeout is 8 seconds so you would need to make some accommodations if you want to keep that 10 second delay.