zoukankan      html  css  js  c++  java
  • mysql创建用户,并指定用户的权限(grant命令)

    1.创建新用户的SQL语句:

         CREATE USER 'pig'@'192.168.1.101_' IDENDIFIED BY '123456';

        // pig 是用户名,@后面的是指定ip(如果不限制只能在某个ip,@后面改为‘%’),by后面的是 密码

    2.设置这个用户的权限,使用GRANT语句

       (如限制某个用户只能查询,不能修改,或者限定只能查询特定的表

          语法:

         mysql> grant 权限1,权限2,...权限n on 数据库名称.表名称 to 用户名@用户地址 identified by '连接口令';

         可选的权限列表:select, insert, update, delete, create, drop,

                          index, alter, grant, references, reload,

                         shutdown, process, file等14个权限

        eg:

          1.  mysql> grant select,insert,update,delete,create,drop on vtdc.employee to joe@10.163.225.87 identified by '123';

            给来自10.163.225.87的用户joe分配可对数据库vtdc的employee表

           进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。

         2. mysql>grant all privileges on vtdc.* to joe@10.163.225.87 identified by '123';

           给来自10.163.225.87的用户joe分配可对数据库vtdc所有表进行所有操作的权限,并设定口令为123。

         3. mysql>grant all privileges on *.* to joe@10.163.225.87 identified by '123';

             给来自10.163.225.87的用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

         4. mysql>grant all privileges on *.* to joe@localhost identified by '123';

             给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。

         5. mysql>flush privileges;   //刷新系统权限表

  • 相关阅读:
    SQL Server中游标的使用
    SQL Server之内连接 左连接 右连接 全连接 交叉连接
    C#后台格式化JSON字符串显示
    使用反射、特性简化代码
    JQuery方法扩展
    .NET强制进行即时垃圾回收
    .NET中的Queue和Stack
    如何解决firefox下window.event的问题
    【JS对象、JSON字符串】之间的相互转换
    Javascript模块化编程(一):模块的写法
  • 原文地址:https://www.cnblogs.com/tommy-huang/p/4210185.html
Copyright © 2011-2022 走看看