1. 程式人生 > >mysql--權限問題

mysql--權限問題

creat 級別 記得 權限 oca 字段 mysq upd ant

#創建用戶
create user ‘lin‘@‘localhost‘ identified by ‘123‘;

#insert,delele,update,select
#級別1:對所有庫,下的所有表,下的所有字段
grant select on *.* to ‘lin1‘@‘localhost‘ identified by ‘123‘;

#級別2:對db1庫,下的所有表,下的所有字段
grant select on db1.* to ‘lin2‘@‘localhost‘ identified by ‘123‘;

#級別3:對表db1.t1,下的所有字段
grant select on db1.t1 to ‘lin3‘@‘localhost‘ identified by ‘123‘;

#級別4:對表db1.t1,下的id,name字段
grant select (id,name) on db1.t1 to ‘lin4‘@‘localhost‘ identified by ‘123‘;
grant select (id,name),update (name) on db1.t1 to ‘lin5‘@‘localhost‘ identified by ‘123‘;

#修改完權限後,要記得刷新權限
flush privileges;


localhost本地主機, identified by以什麽..鑒別
grant 授予,允許. select挑選
create user ‘panyu‘@‘localhost‘ identified by ‘123‘
創建用戶

grant select on *.* to ‘pan‘@‘localhost‘ identified by ‘123‘
授予pan查看所有庫以及所有字段的權限
grant select on db1.* to ‘yu‘@‘localhost‘ identified by ‘123‘;
授予yu查看所有該庫下面的所有表的權限
grant select on db1.t1 to ‘zhuge‘@‘loaclhost‘ identified by ‘123‘;
授予zhuge查看db1庫,下面t1表裏的字段.
grant select (id,name) on db1.t1 to ‘guanyu‘@‘localhost‘ identified by ‘123‘;
grang select (id,name) update(name) on db1.t1 to ‘zhangfei‘@identified by ‘123‘;

mysql--權限問題