MySQL5.7的權(quán)限介紹

本篇內(nèi)容介紹了“MySQL5.7的權(quán)限介紹”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

創(chuàng)新互聯(lián)建站成立與2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項(xiàng)目網(wǎng)站建設(shè)、網(wǎng)站制作網(wǎng)站策劃,項(xiàng)目實(shí)施與項(xiàng)目整合能力。我們以讓每一個(gè)夢(mèng)想脫穎而出為使命,1280元高邑做網(wǎng)站,已為上家服務(wù),為高邑各地企業(yè)和個(gè)人服務(wù),聯(lián)系電話:18980820575

MySQL支持的權(quán)限如下:
ALL或ALL PRIVILEGES 代表指定權(quán)限等級(jí)的所有權(quán)限。
ALTER 允許使用ALTER TABLE來改變表的結(jié)構(gòu),ALTER TABLE同時(shí)也需要CREATE和INSERT權(quán)限。重命名一個(gè)表需要對(duì)舊表具有ALTER和DROP權(quán)限,對(duì)新版具有CREATE和INSERT權(quán)限。
ALTER ROUTINE 允許改變和刪除存儲(chǔ)過程和函數(shù)
CREATE 允許創(chuàng)建新的數(shù)據(jù)庫和表
CREATE ROUTINE 允許創(chuàng)建創(chuàng)建存儲(chǔ)過程和包
CREATE TABLESPACE 允許創(chuàng)建、更改和刪除表空間和日志文件組
CREATE TEMPORARY TABLES 允許創(chuàng)建臨時(shí)表
CREATE USER 允許更改、創(chuàng)建、刪除、重命名用戶和收回所有權(quán)限
CREATE VIEW 允許創(chuàng)建視圖
DELETE 允許從數(shù)據(jù)庫的表中刪除行
DROP 允許刪除數(shù)據(jù)庫、表和視圖
EVENT 允許在事件調(diào)度里面創(chuàng)建、更改、刪除和查看事件
EXECUETE 允許執(zhí)行存儲(chǔ)過程和包
FILE 允許在服務(wù)器的主機(jī)上通過LOAD DATA INFILE、SELECT ... INTO OUTFILE和LOAD_FILE()函數(shù)讀寫文件
GRANT OPTION 允許向其他用戶授予或移除權(quán)限
INDEX 允許創(chuàng)建和刪除索引
INSERT 允許向數(shù)據(jù)庫的表中插入行
LOCK TABLE 允許執(zhí)行LOCK TABLES語句來鎖定表
PROCESS 允許顯示在服務(wù)器上執(zhí)行的線程信息,即被會(huì)話所執(zhí)行的語句信息。這個(gè)權(quán)限允許你執(zhí)行SHOW PROCESSLIST和mysqladmin processlist命令來查看線程,同時(shí)這個(gè)權(quán)限也允許你執(zhí)行SHOW ENGINE命令
PROXY 允許用戶冒充成為另外一個(gè)用戶
REFERENCES 允許創(chuàng)建外鍵
RELOAD 允許使用FLUSH語句
REPLICATION CLIENT 允許執(zhí)行SHOW MASTER STATUS,SHOW SLAVE STATUS和SHOW BINARY LOGS命令
REPLICATION SLAVE 允許SLAVE服務(wù)器連接到當(dāng)前服務(wù)器來作為他們的主服務(wù)器
SELECT 允許從數(shù)據(jù)庫中查詢表
SHOW DATABASES 允許賬戶執(zhí)行SHOW DATABASE語句來查看數(shù)據(jù)庫。沒有這個(gè)權(quán)限的賬戶只能看到他們具有權(quán)限的數(shù)據(jù)庫。
SHOW VIEW 允許執(zhí)行SHOW CREATE VIEW語句
SHUTDOWN 允許執(zhí)行SHUTDOWN語句和mysqladmin shutdown已經(jīng)mysql_shutdown() C API函數(shù)
SUPER 允許用戶執(zhí)行CHANGE MASTER TO,KILL或mysqladmin kill命令來殺掉其他用戶的線程,允許執(zhí)行PURGE BINARY LOGS命令,通過SET GLOBAL來設(shè)置系統(tǒng)參數(shù),執(zhí)行mysqladmin debug命令,開啟和關(guān)閉日志,即使read_only參數(shù)開啟也可以執(zhí)行update語句,打開和關(guān)閉從服務(wù)器上面的復(fù)制,允許在連接數(shù)達(dá)到max_connections的情況下連接到服務(wù)器。
TRIGGER 允許操作觸發(fā)器
UPDATE 允許更新數(shù)據(jù)庫中的表
USAGE 代表沒有任何權(quán)限

授予全局權(quán)限:

*.*代表所有數(shù)據(jù)庫的權(quán)限

mysql> grant all on *.* to 'test'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> grant select, insert on *.* to 'test'@'%';
Query OK, 0 rows affected (0.00 sec)

授予指定數(shù)據(jù)庫的權(quán)限:

mysql> grant all on test.* to 'test'@'localhost';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> grant select, insert on *.* to 'test'@'%';
Query OK, 0 rows affected (0.00 sec)

mysql> grant select, insert on test.* to 'test'@'%';
Query OK, 0 rows affected (0.00 sec)

授予指定表的權(quán)限:

mysql> grant all on test.orders to 'jeffrey'@'localhost';
Query OK, 0 rows affected (0.13 sec)

mysql> grant select, insert on test.orders to 'jeffrey'@'localhost';
Query OK, 0 rows affected (0.07 sec)

授予指定字段的權(quán)限:

mysql> desc test.orders_1;
+---------------+-------------+------+-----+---------+-------+
| Field         | Type        | Null | Key | Default | Extra |
+---------------+-------------+------+-----+---------+-------+
| order_date    | date        | YES  |     | NULL    |       |
| order_id      | int(11)     | YES  |     | NULL    |       |
| customer_name | varchar(15) | YES  |     | NULL    |       |
| product_id    | int(11)     | YES  |     | NULL    |       |
+---------------+-------------+------+-----+---------+-------+
4 rows in set (0.00 sec)

mysql> grant select(order_date), insert(order_id,customer_name) on test.orders_1 to 'jeffrey'@'localhost';
Query OK, 0 rows affected (0.01 sec)

[root@T400-kelong ~]# mysql -ujeffrey -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.10-log MySQL Community Server (GPL)

Copyright (c) 2000, 2015, 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> use test;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> select * from orders_1;
ERROR 1142 (42000): SELECT command denied to user 'jeffrey'@'localhost' for table 'orders_1'

mysql> select order_date from orders_1;
+------------+
| order_date |
+------------+
| 2016-03-26 |
+------------+
1 row in set (0.00 sec)

授予存儲(chǔ)過程的權(quán)限:

mysql> grant create routine on test.* to 'jeffrey'@'localhost';
Query OK, 0 rows affected (0.08 sec)

mysql> grant execute on procedure test.myproc to 'jeffrey'@'localhost';
Query OK, 0 rows affected (0.04 sec)

授予代理用戶權(quán)限:

PROX權(quán)限可以使一個(gè)用戶成為另外一個(gè)用戶的代理

mysql> grant proxy on 'jeffrey'@'localhost' to 'test'@'%';
Query OK, 0 rows affected (0.09 sec)

“MySQL5.7的權(quán)限介紹”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!

分享標(biāo)題:MySQL5.7的權(quán)限介紹
網(wǎng)站鏈接:http://bm7419.com/article6/iidiig.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站建設(shè)網(wǎng)站收錄、網(wǎng)站策劃、手機(jī)網(wǎng)站建設(shè)、網(wǎng)頁設(shè)計(jì)公司

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都定制網(wǎng)站建設(shè)