mysql添加删除用户

2 篇文章 0 订阅

mysql常用的权限增删改查对应的是insert,delete,update,select,但还有show开头的查询如

show variables like "%xx%";
show create table table_name;
。。。。。。

用? show 就可以查看所有与show相关的语句。还有alert等。。。

现在需要添加一个user1,给他所有数据库的所有权限,如下:

grant all privileges on *.*  to user1@localhost identified by 'password1';

只给user2所有数据库的查看权限,如下:

grant select on *.* to user2@localhost identified by 'password2';

只给user3查看数据库database1所有表的权限,如下:

grant select on database1.* to user3@localhost identified by 'password3';

添加的用户可以在数据库mysql表user里查看

select host,user,authentication_string from user;//在版本5.7之前密码字段是password

更新用户密码:

update user set authentication_string=password('new_password') where user='用户名';

删除用户:

delete from user where user='用户名';//确定要删除的用户,可能还要加别的条件
注意:localhost是用户登陆IP,操作完后执行一下 flush privileges 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值