This statement stops and restarts the MySQL server. It requires
One use for
RESTART is when it is
not possible or convenient to gain command-line access to the
MySQL server on the server host to restart it. For example,
PERSIST_ONLY can be used at runtime to make
configuration changes to system variables that can be set only
at server startup, but the server must still be restarted for
those changes to take effect. The
RESTART statement provides a way
to do so from within client sessions, without requiring
command-line access on the server host.
After executing a
statement, the client can expect the current connection to be
lost. If auto-reconnect is enabled, the connection will be
reestablished after the server restarts. Otherwise, the
connection must be reestablished manually.
These platforms provide the necessary monitoring support for the
When the monitoring process detects an exit code of 16, it starts mysqld again. Otherwise, it exits.
Here is a minimal example as implemented in the bash shell:
#!/bin/bash export MYSQLD_PARENT_PID=$$ export MYSQLD_RESTART_EXIT=16 while true ; do bin/mysqld mysqld options here if [ $? -ne $MYSQLD_RESTART_EXIT ]; then break fi done
On Windows, the forking used to implement
RESTART makes determining the
server process to attach to for debugging more difficult. To
alleviate this, starting the server with
--gdb suppresses forking, in
addition to its other actions done to set up a debugging
environment. In non-debug settings,
--no-monitor may be used for the
sole purpose of suppressing forking the monitor process. For a
server started with either
RESTART causes the server to
simply exit without restarting.