zoukankan      html  css  js  c++  java
  • MySQL 权限笔记

    revoke    riˈvōk        撤销

    put an end to the validity or operation of (a decree, decision, or promise).

    privilege    ˈpriv(ə)lij    特权

    a special right, advantage, or immunity granted or available only to a particular person or group of people.
    education is a right, not a privilege

    grant    发放

    a sum of money given by an organization, especially a government, for a particular purpose.
    The money is used for small grants to deserving organizations and individuals.
     
     

    本文的注释全是为了方便起见而写,sql不是这样注释的。

    create user 'u1'@'localhost' identified by '12345';//在localhost 创建一个叫u1的用户, 密码为12345
    
    set password for 'u1'@'localhost' = '12345';    //将密码设置为12345
    GRANT select ON book_reader_db.book TO 'u1'@'localhost';  //给u1 赋予在book表内select的权限
    revoke select on what from 'u1'@'localhost';
    grant all privileges on book_reader_db.* to 'u1'@'localhost';  //给u1 操作数据库所有表的权限
    revoke all privileges on book_reader_db.* from 'u1'@'localhost';//取消权限
    revoke all on book_reader_db.* from 'u1'@'localhost';    //少写一个privileges...最好还是把这个单词背下来。。。
    flush privileges;    //刷新权限
    
    show grants for 'u1'@'localhost';   //显示u1的所有权限
    GRANT SELECT ON `book_reader_db`.`book` TO `u1`@`localhost` WITH GRANT OPTION    //给u1权限的同时也让u1有权力给别的用户权限。
    
    
    grant  create user on *.*  to 'user'@'host';     赋予创建用户的权限。
    
    revoke create user on *.* from 'u1'@'localhost';   删除创建用户的权限。

    上面3条语句都需要重启数据库才能生效

    至于怎样重启数据库。。。

    打开命令行输入net stop mysqlnet start mysql 就好。。。

    我现在在也很想知道怎么撤销给别人权限的权限,除了用revoke all.....

    select * from mysql.user;

    显示所有的用户

    show grants for 'u1'@'localhost';

    显示特定用户的权限

  • 相关阅读:
    正确率、召回率和 F 值
    柯西序列 转自http://blog.sina.com.cn/coopld
    web用户非正常退出的问题
    uploadify上传的文件
    10270 : 青蛙的游戏
    10117 : 数独游戏
    10101 : 正面交锋
    10049 : 凯的菱形
    DARE YOU CLICK ME???(你敢点我吗???)
    高精度专辑(1码题库)
  • 原文地址:https://www.cnblogs.com/incredible-x/p/10045300.html
Copyright © 2011-2022 走看看