mysql受權用戶,撤銷用戶,撤銷權限基本操做

進入mysql庫mysql

use mysql; mysql> select host,user from user; +-----------+---------------+
| host      | user          |
+-----------+---------------+
| %         | root          |
| localhost | mysql.session |
| localhost | mysql.sys     |
| localhost | root          |
+-----------+---------------+
4 rows in set (0.00 sec) select host,user from user where user='root';

將相應用戶數據表中的host字段改爲'%';sql

update user set host='%' where user='root'; update user set host='localhost' where user='root' and host='192.168.%.%'; //ERROR 1062 (23000): Duplicate entry '%-root' for key 'PRIMARY' 不予理會
flush privileges

受權用戶數據庫

grant all privileges on *.* to 'root'@'172.18.%.%' identified by '123456' with grant option; grant all privileges on *.* to 'root'@'192.168.1.%' identified by '123456' with grant option;

撤銷權限session

revoke all privileges on *.* from root@'%'; revoke all privileges on db01.* from root@'%';

刪除用戶ide

drop user 'test'@'localhost';

查看用戶的受權spa

mysql> SHOW GRANTS FOR 'user01'@'%'; +--------------------------------------------------------+
| Grants for user01@%                                 |
+--------------------------------------------------------+
| GRANT USAGE ON *.* TO 'root'@'%'                  |
| GRANT ALL PRIVILEGES ON `db01`.* TO 'user01'@'%' |
+--------------------------------------------------------+
2 rows in set (0.00 sec) //USAGE:create user時的默認的空權限,只能連庫,因此user01如今的權限是在mysql01數據庫上有全部的權限。
相關文章
相關標籤/搜索