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

  • 相关阅读:
    Spring自动装配Beans
    Spring过滤器组件自动扫描
    Spring自动扫描组件
    Spring EL运算符实例
    Spring EL方法调用实例
    Spring EL bean引用实例
    Spring EL hello world实例
    Spring @PostConstruct和@PreDestroy实例
    Spring Bean init-method 和 destroy-method实例
    Spring Bean InitializingBean和DisposableBean实例
  • 原文地址:https://www.cnblogs.com/littleby/p/8481439.html
Copyright © 2011-2022 走看看