MySql数据库------用户授权

用户授权我们涉及到3个对象:

用户名

密码

主机

用户名

密码

主机

Root

1111

localhost

Root

1111

10.10.65.250

laobian

1234

192.168.1.2

1.创建用户

create user laobian@localhost;

2.创建用户并添加密码(123)

create user laobian@localhost identified by "123";

3.创建用户允许远端登录 (允许用户已laobian 登录mysql)

create user [email protected] identified by"123";

 允许10.10.65.0~10.10.65.255的用户以laobian 登录mysql

create user laobian@'10.10.65.%' identified by "123";

 允许10.10.65.25_~10.10.65.255的用户以laobian 登录mysql

create user laobian@'10.10.65.25_' identified by "123";

 删除用户:

drop user laobian@localhost;

drop user [email protected];

授权:

select   查询权限

insert   插入权限

update   更新权限

delete  删除权限

create   创建权限

grant command on database.table  to user@host;
 

Grant select on bian.person to laoiban@localhost 将bian数据库的person表的查询权限授权给以localhost登录laobian用户

Grant insert on bian.person to laoiban@localhost 将bian数据库的person表的插入权限授权给以localhost登录laobian用户

Grant delete on bian.person to laoiban@localhost 将bian数据库的person表的删除权限授权给以localhost登录laobian用户

Grant update on bian.person to laoiban@localhost 将bian数据库的person表的更新权限授权给以localhost登录laobian用户

Grant select(id,name) on bian.person to laoiban@localhost 将bian数据库的person表的id和name字段的查询权限授权给以localhost登录laobian用户

Grant select,insert,update,delete on bian.person to laoiban@localhost 将bian数据库的person表的增删改查的查询权限授权给以localhost登录laobian用户

猜你喜欢

转载自blog.csdn.net/weixin_43567965/article/details/88618169