Reset global MySQL status variables I'm  currently looking into an issue where when running MySQL prepared statement I get an exception:


  SQL Exception: Can't create more than max_prepared_stmt_count statements (current value: 16382)


Looking into this it looks like I'm definetely leaking prepared statements somewhere shown by the global status using the following query:

show global status like 'com_stmt%';


Gives me back the following results:

Com_stmt_close          37693
Com_stmt_execute        54079
Com_stmt_fetch          0
Com_stmt_prepare        54079
Com_stmt_reprepare      0
Com_stmt_reset          0
Com_stmt_send_long_data 0


I'm trying to reset these counters so my app can go back to a normal running state, while I investigate where the prepared statements are being closed but I can't find any way to reset these counters. 

I've tried being logged in to mysql and running flush status, I've tried sending flush-status from the mysql-admin command line utility and I've tried resetting the DB but I can never get it to reset.

I'm using MySQL 5.7
After you are finished with a prepared statement, and executing it, be sure to deallocate_prepare_statement.  I think this will keep the counter from ever climbing to the limit.