Mysql 5.7. 9 shutdown Syntax Example Explanation

  • 2021-08-12 03:51:06
  • OfStack

mysql-5. 7.9 finally provides shutdown syntax:

Before, if you want to close an mysql database, you can use kill command, mysqladmin shutdown, service mysqld stop and so on.

However, after mysql-5. 7.9, mysql finally provides the shutdown syntax for the SQL interface!

shutdown syntax under the SQL interface:

Grammar


shutdown ; --  This shutdown To execute successfully, you must have shutdown Permission is fine. 

An example of shutdown:


[root@workstudio ansible]# mysql -uroot -h127.0.0.1 --  Log in mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.18-enterprise-commercial-advanced-log MySQL Enterprise Server - Advanced Edition (Commercial)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type  ' help; '  or  ' \h '  for help. Type  ' \c '  to clear the current input statement.
mysql> shutdown ; --  Pass SQL Interface is executed in the way of shutdown
Query OK, 0 rows affected (0.00 sec)
--  In mysql Execute under the client system  To execute linux Command   Used here ps To view linux Is there any on the Internet mysqld  This service program is 
mysql> system ps -ef | grep mysql
root    5709  3403 0 13:32 pts/0  00:00:00 mysql -uroot -h127.0.0.1
root    5720  5709 0 13:33 pts/0  00:00:00 sh -c ps -ef | grep mysql
root    5722  5720 0 13:33 pts/0  00:00:00 grep mysql
--  By ps As can be seen from the results of mysql The database has been shut down (mysqld This process is gone )

If the permissions are insufficient, the following effects will be seen:


mysql> shutdown;
ERROR 1227 (42000): Access denied; you need (at least one of) the SHUTDOWN privilege(s) for this operation

Since shutdown is an instance-level permission, the authorization statement is as follows:


mysql> grant shutdown on *.* to jiangle@ ' localhost '  ;
Query OK, 0 rows affected, 1 warning (0.00 sec)
--  Grant jiangle@ ' localhost 'User shutdown Authority 

Related articles: