mysql用户管理

1. 新增用户

  1. mysql>insert into mysql.user(Host,User,Passwordvalues("localhost","lionbule",password("hello1234"));   
  2. mysql>flush privileges;  
mysql>insert into mysql.user(Host,User,Password) values("localhost","lionbule",password("hello1234"));
mysql>flush privileges;

 

2. 修改用户密码

  1. mysql>update mysql.user set password=password('new password'where User="lionbule" and Host="localhost";   
  2. mysql>flush privileges;  
mysql>update mysql.user set password=password('new password') where User="lionbule" and Host="localhost";
mysql>flush privileges;

3. 删除用户

  1. mysql>DELETE FROM user WHERE User="lionbule" and Host="localhost";   
  2. mysql>flush privileges;  
mysql>DELETE FROM user WHERE User="lionbule" and Host="localhost";
mysql>flush privileges;

 

4. 权限分配

    4.1. grant用法

           grant 权限 on 数据库.*to 用户名@'登录主机'identified by '密码'

  1. 权限:   
  2.     常用总结, ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE   
  3. 数据库:   
  4.      *.*                    表示所有库的所有表   
  5.      test.*                表示test库的所有表   
  6.      test.test_table  表示test库的test_table表        
  7. 用户名:   
  8.      mysql账户名   
  9. 登陆主机:   
  10.      允许登陆mysql server的客户端ip   
  11.      '%'表示所有ip   
  12.      'localhost' 表示本机   
  13.      '192.168.10.2' 特定IP   
  14. 密码:   
  15.       账户对应的登陆密码  
权限:
    常用总结, ALL/ALTER/CREATE/DROP/SELECT/UPDATE/DELETE
数据库:
     *.*                    表示所有库的所有表
     test.*                表示test库的所有表
     test.test_table  表示test库的test_table表     
用户名:
     mysql账户名
登陆主机:
     允许登陆mysql server的客户端ip
     '%'表示所有ip
     'localhost' 表示本机
     '192.168.10.2' 特定IP
密码:
      账户对应的登陆密码

 

    4.2 例子

  1. mysql>grant all  on test.* to lionbule@'%' identified by 'hello1234';   
  2. mysql>flush privileges;  
mysql>grant all  on test.* to lionbule@'%' identified by 'hello1234';
mysql>flush privileges;

    新增密码为‘hello234’的用户lionbule对test库拥有所有操作权限,并不限制lionbule用户的登陆IP。     

 

    4.3 注意事项

          grant 会覆盖用户的部分信息,跟insert 、update执行功能一样.

 

参考:

http://dev.mysql.com/doc/refman/5.6/en/grant.html

http://www.cnblogs.com/hcbin/archive/2010/04/23/1718379.html


原文:http://lionbule.iteye.com/blog/1114072

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值