MySQL - RESTART Statement



MySQL RESTART Statement

The RESTART statement stops and restarts the MySQL server. To execute this statement, you need the SHUTDOWN privilege. Though you don’t have command line access on the server you can restart the server from client sessions.

RESTART;

After executing the RESTART statement, if you try to execute any other MySQL commands (other than USE) you will get an error as shown below −

SHOW TABLES;
ERROR 2013 (HY000): Lost connection to MySQL server during query

After the restart you need to select a database then it will reconnect displaying the following message −

use test;
No connection. Trying to reconnect...
Connection id: 8
Current database: *** NONE ***

Database changed

Now, you can successfully execute other MySQL statements.

select * from test;

following is the output of the above query −

data
Name
Advertisements