mysql-5.7.9 shutdown 文法詳解

來源:互聯網
上載者:User

標籤:err   reg   and   style   row   monitor   分享   資料   mysqld   

mysql-5.7.9 終於提供shutdown 文法啦

  之前如果想關閉一個mysql資料庫可以通過kill 命令、mysqladmin shutdown 、service mysqld stop 等這樣的方式。

  然而在mysql-5.7.9之後mysql終於提供了SQL介面的shutdown文法啦!

 

SQL介面下的shutdown文法

  文法

shutdown ; -- 這個shutdown要執行成功要有shutdown許可權才行。

 

shutdown的一個例子

[[email protected] ansible]# mysql -uroot -h127.0.0.1  -- 登入進mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 3Server 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.mysql> shutdown ; -- 通過SQL介面的方式執行shutdownQuery OK, 0 rows affected (0.00 sec)-- 在mysql用戶端下執行system 來執行linux命令 這裡用ps來查看linux上有沒有mysqld 這個服務程式了mysql> system ps -ef | grep mysqlroot       5709   3403  0 13:32 pts/0    00:00:00 mysql -uroot -h127.0.0.1root       5720   5709  0 13:33 pts/0    00:00:00 sh -c  ps -ef | grep mysqlroot       5722   5720  0 13:33 pts/0    00:00:00 grep mysql-- 由ps的結果可以看出mysql資料庫已經關閉了(mysqld這個進程沒有了)

 

如果許可權不足會看下如下效果

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

 

由於shutdown是執行個體級的許可權、所以授權語句如下

mysql> grant shutdown on *.* to [email protected]‘localhost‘ ;Query OK, 0 rows affected, 1 warning (0.00 sec)-- 授予[email protected]‘localhost‘使用者shutdown許可權

 

----

學習交流

mysql-5.7.9 shutdown 文法詳解

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.