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;   //刷新系统权限表

  • 相关阅读:
    tomcat2章1
    tomcat1章1
    线程安全的CopyOnWriteArrayList
    Java Security: Illegal key size or default parameters?
    struct和typedef struct
    C可变参数函数 实现
    C和C++混合编程(__cplusplus 与 external "c" 的使用)
    WebRTC之带宽控制部分学习(1) ------基本demo的介绍
    WebRTC代码走读(八):代码目录结构
    webrtc中的带宽自适应算法
  • 原文地址:https://www.cnblogs.com/tommy-huang/p/4210185.html
Copyright © 2011-2022 走看看