mysql用户和权限管理

一、mysql用户和权限管理

1.1 用户管理包括:

  • 创建用户 create user xwp@'%' identified by '12345678';
  • 修改用户密码 set password for xwp = password('123456');
  • 用户重命名 rename user xwp to xwphs;
  • 删除用户 drop user xwphs@'%';

1.2 权限管理

  • 查看权限 show grants for xwphs@'%';
  • 用户授权 grant select(all privileges) on *.* to xwphs@'%' with grant option;
  • 撤销授权 revoke all privileges on *.* from xwphs@'%';

1.3 示例

-- 查看用户表
select * from mysql.user;

-- 创建用户
create user xwp@'%' identified by 'nsbg1111*';

-- 修改密码1
set password for xwp@'%' = password('xwphshaha');
-- 修改密码2
update mysql.user set authentication_string = password('xwphsheihei') where `user`='xwp' and `host`='%';
flush privileges;

-- 重命名
rename user xwp to xwphs;

-- 查询用户权限
show grants for xwphs@'%';

-- 用户授权
grant select on *.* to xwphs@'%';
grant all privileges on *.* to xwphs@'%' with grant option;

-- 撤销权限
revoke select on *.* from xwphs@'%';
revoke all privileges on *.* from xwphs@'%';

-- 删除用户
drop user xwphs@'%';
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值