zoukankan      html  css  js  c++  java
  • mysql基本操作

    #访问控制

    ##登录mysql

    mysql -u root -p
    

    ##查看所有用户

    select user from mysql.user
    

    ##创建用户

    CREATE USER 'username'@'host' IDENTIFIED BY 'password';
    

    ##删除用户

    注意必须明确给出该账号的主机名

    drop user 'test'@'localhost';
    

    ##重命名用户

    rename user 'test'@'localhost'to'foo'@'localhost';
    

    ##修改密码

    set password for 'test'@'localhost'=password('hello');
    

    #权限管理

    ##查看权限

    show grants for 'test'@'localhost';
    

    ##授权

    grant select(cust_id,cust_name)
        on mysql_test.customers
        to'zhangsan'@'localhost';--授予在数据库mysql_test的表customers上拥有对列cust_id和列cust_name的select权限
    

      

    grant select ,update
        on mysql_test.customers
        to 'liming'@'localhost'identified by'123';--新建一个用户为liming,并授予其在数据库mysql_test的表customers上拥有select和update的权限
    

      

    grant all
        on mysql_test.*
        to'zhangsan'@'localhost';--授予可以在数据库mysql_test中执行所有操作的权限
    

      

    grant create user
        on *.*
        to'zhangsan'@'localhost';--授予系统中已存在用户zhangsan拥有创建用户的权限
    

    ##权限的转移

    grant select,update
        on mysql_test.customers
        to'zhou'@'localhost'identified by'123'
        with grant option;
    

    如果上面with子句后面跟的是

    max_queries_per_hour count、 
    max_updates_per_hour count、 
    max_connections_per_hour count、 
    max_user_connections count 
    中的某一项,则该grant语句可用于限制权限

    grant delete
        on mysql_test.customers
        to 'zhangsan'@'localhost'
        with max_queries_per_hour 1;--每小时只能处理一条delete语句的权限
    

    ##权限的撤销

    revoke select 
        on mysql_test.customers
        from'zhangsan'@'localhost';--回收用户zhangsan在数据库mysql_test的表customers上的select权限
    

    搬运自http://blog.csdn.net/ParanoidYang/article/details/61951265

  • 相关阅读:
    CBR(基于案例的推理)的产生和Roger Schank=Schank教授在他的著作中提出了以“记忆组织包"
    php 设计模式
    php 常用资源
    自然语言处理著作或期刊名称2
    北京师范大学语言学及应用语言学研究生培养方案
    !!! Analysis & Design 很好的汇总+zcl的 UML 体会
    睡眠的方法
    !!!【php100教程】
    机器翻译和自然语言信息处理专业硕士研究生培养方案
    愧薪
  • 原文地址:https://www.cnblogs.com/littleby/p/8481439.html
Copyright © 2011-2022 走看看