mysql 對使用者授權的操作
阿新 • • 發佈:2019-01-07
mysql> use mysql ; #zhaoyun使用者對mysql資料庫沒有任何許可權。
ERROR 1044 (42000): Access denied for user 'zhaoyun'@'localhost' to database 'mysql'
mysql>
mysql> use zhaoyun ; #可以使用zhaoyun資料庫
Database changed
mysql> show grants ; #檢視當前使用者擁有的許可權
+--------------------------------------------------------------------------------------+
| Grants for [email protected] |
+--------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zhaoyun'@'localhost' |
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ON `zhaoyun`.* TO 'zhaoyun'@'localhost' |
+--------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> create table test(user char(3)); #建表測試
Query OK, 0 rows affected (0.00 sec)
ERROR 1044 (42000): Access denied for user 'zhaoyun'@'localhost' to database 'mysql'
mysql>
mysql> use zhaoyun ; #可以使用zhaoyun資料庫
Database changed
mysql> show grants ; #檢視當前使用者擁有的許可權
+--------------------------------------------------------------------------------------+
| Grants for
+--------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zhaoyun'@'localhost' |
| GRANT SELECT, INSERT, UPDATE, DELETE, CREATE ON `zhaoyun`.* TO 'zhaoyun'@'localhost'
+--------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
mysql> create table test(user char(3)); #建表測試
Query OK, 0 rows affected (0.00 sec)