国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數(shù)據(jù)庫 > MySQL > 正文

MySQL查詢用戶權(quán)限的方法總結(jié)

2024-07-24 12:54:35
字體:
供稿:網(wǎng)友

介紹兩種查看MySQL用戶權(quán)限的兩種方法

1、 使用MySQL grants命令

mysql> show grants for username@localhost;+---------------------------------------------------------------------+| Grants for root@localhost |+---------------------------------------------------------------------+| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |+---------------------------------------------------------------------+

需要注意的是:

● username和ip的組合需要是在mysql.user表中存在的,具體可以通過 select * from mysql.user 命令查看

● ip地址如果是通配符格式需要加引號(hào),例如:show grants for root@'172.%';

2、 使用MySQL select命令

mysql> select * from mysql.user where user='root' and host='localhost' /G;*************************** 1. row ***************************Host: localhostUser: rootPassword: **********************Select_priv: YInsert_priv: YUpdate_priv: YDelete_priv: YCreate_priv: YDrop_priv: YReload_priv: YShutdown_priv: YProcess_priv: YFile_priv: YGrant_priv: YReferences_priv: YIndex_priv: YAlter_priv: YShow_db_priv: YSuper_priv: YCreate_tmp_table_priv: YLock_tables_priv: YExecute_priv: YRepl_slave_priv: YRepl_client_priv: YCreate_view_priv: YShow_view_priv: YCreate_routine_priv: YAlter_routine_priv: YCreate_user_priv: YEvent_priv: YTrigger_priv: YCreate_tablespace_priv: Yssl_type:ssl_cipher:x509_issuer:x509_subject:max_questions: 0max_updates: 0max_connections: 0max_user_connections: 0plugin: mysql_native_passwordauthentication_string:password_expired: N1 row in set (0.01 sec)

 

知識(shí)點(diǎn)擴(kuò)展:

我們來創(chuàng)建一個(gè)測試賬號(hào)test,授予表層級的權(quán)限

mysql> drop user test;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)mysql> grant all on MyDB.kkk to test@'%' identified by 'test';Query OK, 0 rows affected (0.01 sec)mysql> mysql> show grants for test;+-----------------------------------------------------------------------------------------------------+| Grants for test@% |+-----------------------------------------------------------------------------------------------------+| GRANT USAGE ON *.* TO 'test'@'%' IDENTIFIED BY PASSWORD '*94BDCEBE19083CE2A1F959FD02F964C7AF4CFC29' || GRANT ALL PRIVILEGES ON `MyDB`.`kkk` TO 'test'@'%' |+-----------------------------------------------------------------------------------------------------+2 rows in set (0.00 sec)mysql> select * from mysql.tables_priv/G;*************************** 1. row ***************************Host: %Db: MyDBUser: testTable_name: kkkGrantor: root@localhostTimestamp: 0000-00-00 00:00:00Table_priv: Select,Insert,Update,Delete,Create,Drop,References,Index,Alter,Create View,Show view,TriggerColumn_priv: 1 row in set (0.01 sec)ERROR: No query specifiedmysql> <br>            
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 荔波县| 衡水市| 松桃| 四川省| 桐梓县| 水富县| 五莲县| 贵德县| 宁晋县| 唐山市| 万载县| 德安县| 上饶县| 滦平县| 山阴县| 定西市| 海安县| 澳门| 南宫市| 梓潼县| 百色市| 黄梅县| 三亚市| 海伦市| 永宁县| 同仁县| 东阳市| 遂宁市| 丹凤县| 乐安县| 长汀县| 南和县| 柏乡县| 库尔勒市| 延庆县| 景东| 太康县| 翼城县| 韶山市| 大洼县| 吴堡县|