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