mysql权限管理

权限管理
    1、创建账号
    #本地账号
    create user "egon1"@"localhost" identified by "123";        # mysql -uegon1 -p123
    #远程账号
    create user "egon2"@"192.168.31.10" identified by "123";    # mysql -uegon2 -p123 -h 服务端ip
    create user "egon3"@"192.168.31.%" identified by "123";     # mysql -uegon3 -p123 -h 服务端ip
    create user "egon4"@"%"        identified by "123"     # mysql -uegon4 -p123 -h 服务端ip
    
    
    2、授权
    user:*.*
    db:db1.*
    tables_priv:db1.t1
    conumns_priv:id,name
    
    grant all on *.* to "egon1"@"localhost";      # 除了授权权限外的所有权限
    grant select on *.* to "egon1"@"localhost";
    revoke select on *.* from "egon1"@"localhost";
    
    grant select on db1.* to "egon1"@"localhost";
    revoke select on db1.* from "egon1"@"localhost"
    
    grant select on db1.t2 to "egon1"@"localhost";
    revoke select on db1.t2 from "egon1"@"localhost";
    
    grant select(id,name),update(age) on db1.t2 to "egon1"@"localhost";
    
    

 

posted @ 2018-07-05 08:18  慕沁  阅读(113)  评论(0)    收藏  举报