Mysql 5.7.9 shutdown 語(yǔ)法實(shí)例詳解
mysql-5.7.9 終于提供shutdown 語(yǔ)法啦:
之前如果想關(guān)閉一個(gè)mysql數(shù)據(jù)庫(kù)可以通過(guò)kill 命令、mysqladmin shutdown 、service mysqld stop 等這樣的方式。
然而在mysql-5.7.9之后mysql終于提供了SQL接口的shutdown語(yǔ)法啦!
SQL接口下的shutdown語(yǔ)法:
語(yǔ)法
shutdown ; -- 這個(gè)shutdown要執(zhí)行成功要有shutdown權(quán)限才行。
shutdown的一個(gè)例子:
[root@workstudio ansible]# mysql -uroot -h127.0.0.1 -- 登錄進(jìn)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 ; -- 通過(guò)SQL接口的方式執(zhí)行shutdown Query OK, 0 rows affected (0.00 sec) -- 在mysql客戶端下執(zhí)行system 來(lái)執(zhí)行l(wèi)inux命令 這里用ps來(lái)查看linux上有沒(méi)有mysqld 這個(gè)服務(wù)程序了 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 -- 由ps的結(jié)果可以看出mysql數(shù)據(jù)庫(kù)已經(jīng)關(guān)閉了(mysqld這個(gè)進(jìn)程沒(méi)有了)
如果權(quán)限不足會(huì)看下如下效果:
mysql> shutdown; ERROR 1227 (42000): Access denied; you need (at least one of) the SHUTDOWN privilege(s) for this operation
由于shutdown是實(shí)例級(jí)的權(quán)限、所以授權(quán)語(yǔ)句如下:
mysql> grant shutdown on *.* to jiangle@‘localhost‘ ; Query OK, 0 rows affected, 1 warning (0.00 sec) -- 授予jiangle@‘localhost‘用戶shutdown權(quán)限
以上所述是小編給大家介紹的Mysql 5.7.9 shutdown 語(yǔ)法實(shí)例詳解,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)本站網(wǎng)站的支持!
版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信