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

  • 相关阅读:
    【转】C# 注册表简单操作
    [转]VC++之随父窗口变化调整控件大小/位置
    [转]vc 汉字汉语拼音首字母如何获取
    [转]浅析ActiveX控件的CAB压缩
    [转]VC6.0中使用MFC开发ActiveX及简单验证
    ElasticSearch增加索引字段
    单词缩写
    linux命令
    使用PR插件Twixtor Pro对视频补帧
    Linux创建脚本服务
  • 原文地址:https://www.cnblogs.com/tommy-huang/p/4210185.html
Copyright © 2011-2022 走看看