mysql添加删除用户

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 

版权声明:本文为wl_1013原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。