mysql-5.7.9 finally provides shutdown syntax :
Before you can turn off a MySQL database by using the KILL command, mysqladmin shutdown, service mysqld stop, and so on.
However, after mysql-5.7.9 MySQL finally provided the SQL interface shutdown syntax!
shutdown syntax under the SQL interface :
Grammar
shutdown -- This shutdown must have shutdown permission to execute successfully.
An example of shutdown :
[[email protected] ansible]# MySQL-Uroot-h127.0.0.1 --log into MySQLWelcome toThe MySQL Monitor. CommandsEnd with;or\g.your MySQL Connection ID is 3Server Version:5.7. --Enterprise-Commercial-Advanced-LogMySQL Enterprise Server-Advanced Edition (commercial) Copyright (c) -, ., Oracleand/orits affiliates. Allrights reserved. Oracle isA registered trademark ofOracle Corporationand/oritsaffiliates. Names may trademarks oftheir respectiveowners. Type'Help ;' or '\h' forHelp. Type'\c' toClear the Currentinput Statement.mysql> shutdown;--execute shutdown through the SQL interfaceQuery OK,0Rows Affected (0.00sec)--execute the system under MySQL client to execute the Linux command here's a PS to see if there's Mysqld on Linux.Mysql>System PS-Ef|grep mysqlroot5709 3403 0 -: +Pts/0 xx:xx:xxMysql-Uroot-h127.0.0.1Root5720 5709 0 -: -Pts/0 xx:xx:xxSh-C PS-Ef|grep mysqlroot5722 5720 0 -: -Pts/0 xx:xx:xxgrep MySQL--the results from PS show that the MySQL database is closed (mysqld This process is not available)
If you have insufficient permissions, you will see the following effect :
MySQL>shutdown1227 (42000ofshutdownfor This operation
because shutdown is an instance-level permission, the authorization statement is as follows :
MySQL>Grantshutdownon*. * to [Email protected] ' localhost ' 01 Warning (0.00 sec)-- Grant [email protected] ' LocalHost ' User shutdown permissions
----
Learning Communication
mysql-5.7.9 Shutdown Syntax Explanation