test: 用户名
michael123: 密码
localhost: 只有本机可以访问
create user 'michael'@'%' identified by 'michael123';
%:任何电脑都可以访问
create user 'winter'@'9.110.238.211' identified by 'winter123';
9.110.238.211:winter只能从这个ip登录
密码为空:winter01不需要密码登陆服务器。
create database mysql01;
drop database mysql01;
use mysql01;
GRANT ALL ON mysql01.* TO 'michael'@'%'
ALL: 所以权限,也可以单独制定delete, select, update, insert
mysql01: 在这个数据库上的权限
michael:用户
%:任何有michael的电脑上
创建用户winter01,密码winter123,同时赋给winter01在mysql01数据库上所有的权限
刷新权限
flush privileges;
--create user 'michael02'@'%' identified by 'michael123';
--GRANT ALL ON mysql01.* TO 'michael02'@'%';
--GRANT INSERT ON mysql01.* TO 'michael02'@'%';
--GRANT SELECT ON mysql01.* TO 'michael02'@'%';
--flush privileges;
查看michael02的权限
SHOW GRANTS FOR 'michael02'@'%';
撤销michael02所有的权限
REVOKE ALL ON mysql01.* FROM 'michael02'@'%';
--REVOKE INSERT ON mysql01.* FROM 'michael02'@'%';
--REVOKE SELECT ON mysql01.* FROM 'michael02'@'%';
drop user 'test'@'localhost';