grant all privileges on dbname.* to username@localhost identified by ‘password’; # 创建用户并授权
列表说明参数:
| grant | all privileges | on dbname.* | to username@localhost | identified by ‘password’ |
| -- | -- | -- | -- | -- |
| 授权命令 | 对应权限 | 目标:库和表 | 用户名和客户端主机 | 用户密码 |
说明:上述命令是授权localhost主机上通过username管理dbname数据库的所有权限,密码为password。其中username,dbname,password根据业务情况自行修改。
CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'password'; # 创建用户
grant all privileges on test.* to 'jeffrey'@'localhost'; # 给用户授权
show grants for 'jeffrey'@'localhost'; # 查看用户权限明细
grant all on *.* to username@'192.168.1.%' identified by 'password'; # 百分号匹配
grant all on *.* to username@'192.168.1.0/255.255.255.0' identified by 'password'; # 子网掩码配置
DROP USER 'jeffrey'@'localhost';
insert,
select,
update,
delete,
create,
drop,
references,
index,
alter,
create temporary tables,
lock tables,
execute,
create view,
show view,
create routine,
alter routine,
event,
trigger
grant SELECT, RELOAD, SHOW DATABASES, LOCK TABLES, REPLICATION CLIENT, EVENT,TRIGGER ON *.* TO 'back_user'@'Host' IDENTIFIED BY 'Password';
flush privileges;
权限列表
内容来源于网络,如有侵权,请联系作者删除!