You can call the mysql_shutdown() function to shut down a database server.
Syntax
int
mysql_shutdown(MYSQL *mysql,
enum mysql_enum_shutdown_level shutdown_level)
Return values
0 is returned for an execution success, and a non-zero value is returned if an error occurred.
Errors
CR_COMMANDS_OUT_OF_SYNC: Commands were executed in an improper order.CR_SERVER_GONE_ERROR: The connection to the OBServer was disconnected.CR_SERVER_LOST: The connection to the server was lost during the query.CR_UNKNOWN_ERROR: An unknown error occurred.
Notes
The logged-on user must have the SHUTDOWN privilege.
A MySQL server can be shut down only by calling this function. shutdown_level must be equal to SHUTDOWN_DEFAULT.