6-3 MySQL授权
最后更新于:2022-04-02 07:44:25
### 创建数据库:
mysql> create database max_finance_dev;
mysql> create database max_finance_test;
授权用户:
mysql> CREATE USER 'finance'@'%' IDENTIFIED BY 'e@finance';
mysql> grant all on max_finance_dev.* TO 'finance'@'%';
mysql> grant all on max_finance_test.* TO 'finance'@'%';
### 查看用户权限:
mysql> show grants for 'finance'@'%';
+----------------------------------------------------------------------+
| Grants for finance@% |
+----------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'finance'@'%' |
| GRANT ALL PRIVILEGES ON `max_finance_test`.* TO 'finance'@'%' |
| GRANT ALL PRIVILEGES ON `finance_dev`.* TO 'finance'@'%' |
+----------------------------------------------------------------------+
4 rows in set (0.00 sec)
### 权限回收
mysql> revoke all PRIVILEGES ON `finance`.* from 'finance'@'%'
mysql> show grants for 'finance'@'%';
+----------------------------------------------------------------------+
| Grants for finance@% |
+----------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'finance'@'%' |
| GRANT ALL PRIVILEGES ON `max_finance_test`.* TO 'finance'@'%' |
| GRANT ALL PRIVILEGES ON `max_finance_dev`.* TO 'finance'@'%' |
+----------------------------------------------------------------------+
3 rows in set (0.00 sec)
';