91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

MySQL如何使用GRANT授權某用戶瀏覽和修改表權限操作

發布時間:2021-11-03 09:31:00 來源:億速云 閱讀:402 作者:小新 欄目:MySQL數據庫

小編給大家分享一下MySQL如何使用GRANT授權某用戶瀏覽和修改表權限操作,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

下面的例子是授權logger用戶查詢,插入和修改test數據庫表記錄,但不能刪除的一個例子:
C:\Users\duansf>mysql -u root -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.5.13 MySQL Community Server (GPL)


Copyright (c) 2000, 2010, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| db_shop            |
| frag_test          |
| mysql              |
| performance_schema |
| test               |
+--------------------+


mysql> use test
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| workinfo       |
+----------------+
1 row in set (0.03 sec)


mysql> select * from workinfo;        
Empty set (0.12 sec)                      --表記錄為空

mysql> grant select,insert,update on test.workinfo to logger@localhost identified by 'timber';     --授權logger用戶訪問和修改test數據庫的workinfo表
Query OK, 0 rows affected (0.14 sec)
mysql> quit
Bye


C:\Users\duansf>mysql -h localhost -u logger -p      --用logger用戶登錄數據庫
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.5.13 MySQL Community Server (GPL)


Copyright (c) 2000, 2010, 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>


mysql> select * from workinfo;        --可以查詢
Empty set (0.12 sec)


mysql> desc workinfo;
+----------+-------------+------+-----+---------+----------------+
| Field    | Type        | Null | Key | Default | Extra          |
+----------+-------------+------+-----+---------+----------------+
| id       | int(10)     | NO   | PRI | NULL    | auto_increment |
| name     | varchar(20) | NO   |     | NULL    |                |
| type     | varchar(10) | YES  |     | NULL    |                |
| address  | varchar(50) | YES  |     | NULL    |                |
| tel      | varchar(20) | YES  |     | NULL    |                |
| wages    | int(11)     | YES  |     | NULL    |                |
| contents | tinytext    | YES  |     | NULL    |                |
| extra    | text        | YES  |     | NULL    |                |
+----------+-------------+------+-----+---------+----------------+
8 rows in set (0.02 sec)


mysql> insert into workinfo values(3,'chenfeng','type','zhengzhou','123456',22,1,1);      --有插入權限
Query OK, 1 row affected (0.13 sec)


mysql> select * from workinfo;      --有查詢權限
+----+----------+------+-----------+--------+-------+----------+-------+
| id | name     | type | address   | tel    | wages | contents | extra |
+----+----------+------+-----------+--------+-------+----------+-------+
|  3 | chenfeng | type | zhengzhou | 123456 |    22 | 1        | 1     |
+----+----------+------+-----------+--------+-------+----------+-------+
1 row in set (0.00 sec)



mysql> update workinfo set name='duansf' where id=3;         --有修改權限
Query OK, 1 row affected (0.13 sec)
Rows matched: 1  Changed: 1  Warnings: 0


mysql> select * from workinfo;
+----+--------+------+-----------+--------+-------+----------+-------+
| id | name   | type | address   | tel    | wages | contents | extra |
+----+--------+------+-----------+--------+-------+----------+-------+
|  3 | duansf | type | zhengzhou | 123456 |    22 | 1        | 1     |
+----+--------+------+-----------+--------+-------+----------+-------+
1 row in set (0.00 sec)


mysql>


mysql> delete from workinfo where id=3;          --無刪除權限,以下是報錯信息
ERROR 1142 (42000): DELETE command denied to user 'logger'@'localhost' for table
 'workinfo'

看完了這篇文章,相信你對“MySQL如何使用GRANT授權某用戶瀏覽和修改表權限操作”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

枞阳县| 康平县| 巨鹿县| 兴国县| 郴州市| 江源县| 广汉市| 肃宁县| 揭阳市| 体育| 云霄县| 甘肃省| 阳谷县| 大兴区| 万州区| 法库县| 苏尼特左旗| 涟水县| 阳东县| 花垣县| 德江县| 贞丰县| 郧西县| 无棣县| 五原县| 呼和浩特市| 区。| 江达县| 永兴县| 巴彦县| 塔河县| 甘德县| 沙坪坝区| 保靖县| 敦化市| 奉贤区| 鹤峰县| 蛟河市| 宣城市| 曲水县| 弥渡县|