mysql四-2:权限管理

权限管理

#授权操作只能通过root用户!!set global validate_password_policy=0;set global validate_password_length=1;# 安全设置问题,查看这个:http://www.jb51.net/article/95399.htm创建账号:  # 本地账号  create user egon@localhost identified by 1234; # mysql -uegon -p123  # 远程账号  create user egon@192.168.31.10 identified by 1234; # mysql -uegon -p123 -h 服务端ip # 让一个网段内所有机器都可以登录 create user egon@192.168.31.% identified by 1234; # 让所有能Ping通机器都可以登录 create user egon@% identified by 1234;授权级别 user:*.* 对所有库所有表 db:db1.* 对db1库里所有表 table_priv:db1.t1 对某一个表开放权限 columns_priv:id,name 对某一个字段开放权限授权方法 # user级别 select * from mysql.user\G;可以查看授权情况 # 授权  grant select on *.*; 授权所有库所有表的select grant select on *.* to egon@localhost; grant all on *.* to egon@localhost; 授权对所有库下所有表的权限(all不包含grant权限) # 收回权限 revoke select on *.* from egon@localhost; # db级别 select * from mysql.db\G;可以查看授权情况 # 授权 grant selcect on db1.* to egon@localhost; # 收回权限 revoke select on db1.* from egon@localhost; # table select * from mysql.tables_priv\G;查看授权情况 # 授权 grant select on db1.t2 to egon@localhost; # 收回权限 revoke select on db1.t2 from egon@localhost; # 字段级别 # 授权 grant select(id,name), update(age) on db1.t2 to egon@localhost; # 字段的查看、字段的更新权限 # 收回权限 revoke select(id,name),update(age) from db1.t2 to egon@localhost; 

 

相关文章