用户操作

  1. 创建用户
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
# create user 'test'@'localhost' identified by 'test1234';
  1. 授权
grant privileges on db.table to 'username'@'host'
# grant select,update on test.user to 'test'@'localhost';
  1. 创建用户同时授权
grant all privileges on *.* to 'username'@'host' identified by 'password';
# grant all privileges on test.* to 'test2'@'localhost' identified by 'test1234';
  1. 切记执行 flush privileges;
flush privileges;
  1. 收回权限
REVOKE privilege ON db.tablename FROM 'username'@'host';
# revoke update on test.user from 'test'@'localhost';
  1. 删除用户
DROP USER 'username'@'host';
# drop user 'test'@'localhost';
  1. 查询用户权力
show grants for 'username'@'host';
# show grants for 'test'@'localhost';

你可能感兴趣的:(用户操作)