创建账号:
create user 'yy'@'127.0.0.1' identified by '123';
删除用户:
drop user 'yy'@'127.0.0.1';
修改用户:
rename user 'yy'@'127.0.0.1' to 'zz'@'10.10.80.44';
授权表权限:
-- 用户zz拥有所有数据库的所有权限
grant all privileges on *.* TO 'zz'@'localhost';
-- 用户zz拥有数据库db的所有权限
grant all privileges on db.* TO 'zz'@'localhost';
-- 用户zz拥有数据库db中message表的所有权限
grant all privileges on db.message TO 'zz'@'localhost';
-- 用户zz拥有数据库db所有表的查询和插入权限
grant select,insert on db.* TO 'zz'@'localhost';
-- 将数据读取到内存中,从而立即生效。
flush privileges;
查看授权
show grants for 'zz'@'10.10.80.44';
取消授权
revoke ALL PRIVILEGES on db.* from 'zz'@'10.10.80.44';
flush privileges;