mysql 建立用户, 授权用户


1 建立用户

    mysql>create user 'username'@'host' identified by 'password';
        host 指定用户登录位置, 本机登录为localhost,  任意主机为%

2 用户授权
    mysql>grant privileges on dbname.tbname to 'username'@'host';
        privileges 权限列表     
         GRANT SELECT, INSERT ON test.user TO 'pig'@'%';
         GRANT ALL ON *.* TO 'pig'@'%';
         
--------------------------------------------------------------------------------------------------------
创建用户并授权
    mysql>grant privileges on dbname.tbname to 'username'@'host' identified by 'password' with grant option
     privileges 权限列表   
     with grant option 是授权给用户可以继续给他人授权
--------------------------------------------------------------------------------------------------------         
         
3 设置密码
    mysql>set password for 'username'@'host' =password('password');
        对当前登录用户设置密码: set password = password('password');
        
4 撤销授权
    mysql>revoke privileges on dbname.tbname to 'username'@'host';
        通授权模式
        
5 删除用户
    mysql>drop user 'username'@'host';
    
    
6 设置生效
    mysql>flush privileges;    
            
       

posted @ 2014-03-26 16:06  青松梧桐  阅读(147)  评论(0编辑  收藏  举报