查看用户权限

show grants for 你的用户

比如:
show grants for root@’localhost’;

mysql> use mysql;

Database changed

mysql> select user,host from user;

+———+———————–+

| user    | host                  |

+———+———————–+

| root    | 127.0.0.1             |

|         | localhost             |

| root    | localhost             |

|         | localhost.localdomain |

| root    | localhost.localdomain |

+———+———————–+

7 rows in set (0.00 sec)

mysql> show grants for root@’localhost’;

+———————————————————————+

| Grants for root@localhost                                           |

+———————————————————————+

| GRANT ALL PRIVILEGES ON *.* TO ‘root’@'localhost’ WITH GRANT OPTION |

+———————————————————————+

1 row in set (0.00 sec)

mysql>

mysql> select  db,user ,host  from db;

+———+——+————–+

| db      | user | host         |

+———+——+————–+

| test    |      | %            |

| test\_% |      | %            |

| db      | test | 172.20.1.124 |

+———+——+————–+

3 rows in set (0.00 sec)

mysql>

Grant 用法

mysql> GRANT ON

-> TO [IDENTIFIED BY ""]

-> [WITH GRANT OPTION];

例如:GRANT USAGE ON *.* TO ‘discuz’@'localhost’ IDENTIFIED BY PASSWORD ’123456′;

参数说明:

是一个用逗号分隔的你想要赋予的权限的列表。你可以指定的权限可以分为三种类型:

数据库/数据表/数据列权限:

Alter: 修改已存在的数据表(例如增加/删除列)和索引。

Create: 建立新的数据库或数据表。

Delete: 删除表的记录。

Drop: 删除数据表或数据库。

INDEX: 建立或删除索引。

Insert: 增加表的记录。

Select: 显示/搜索表的记录。

Update: 修改表中已存在的记录。

全局管理权限:

file: 在MySQL服务器上读写文件。

PROCESS: 显示或杀死属于其它用户的服务线程。

RELOAD: 重载访问控制表,刷新日志等。

SHUTDOWN: 关闭MySQL服务。

特别的权限:

ALL: 允许做任何事(和root一样)。

USAGE: 只允许登录–其它什么也不允许做。

============================================

mysql更改用户权限
This entry was posted by admin Monday, 26 April, 2010
1.“grant all on *.* to root@’%’ identified by ‘yourpassword’;”——这个还可以顺带设置密码。
2.“flush privileges; ”——刷新一下,让权限生效。
mysql的一些其他的管理,可以用mysqladmin命令。可以用来设置密码什么的。
grant方面的详细信息可以看我下面的转载:
本文实例,运行于 MySQL 5.0 及以上版本。
MySQL 赋予用户权限命令的简单格式可概括为:
grant 权限 on 数据库对象 to 用户
一、grant 普通数据用户,查询、插入、更新、删除 数据库中所有表数据的权利。
grant select on testdb.* to common_user@’%’
grant insert on testdb.* to common_user@’%’
grant update on testdb.* to common_user@’%’
grant delete on testdb.* to common_user@’%’
或者,用一条 MySQL 命令来替代:
grant select, insert, update, delete on testdb.* to common_user@’%’
二、grant 数据库开发人员,创建表、索引、视图、存储过程、函数。。。等权限。
grant 创建、修改、删除 MySQL 数据表结构权限。
grant create on testdb.* to developer@’192.168.0.%’;
grant alter on testdb.* to developer@’192.168.0.%’;
grant drop   on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 外键权限。
grant references on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 临时表权限。
grant create temporary tables on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 索引权限。
grant index on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 视图、查看视图源代码 权限。
grant create view on testdb.* to developer@’192.168.0.%’;
grant show   view on testdb.* to developer@’192.168.0.%’;
grant 操作 MySQL 存储过程、函数 权限。
grant create routine on testdb.* to developer@’192.168.0.%’; — now, can show procedure status
grant alter routine on testdb.* to developer@’192.168.0.%’; — now, you can drop a procedure
grant execute        on testdb.* to developer@’192.168.0.%’;
三、grant 普通 DBA 管理某个 MySQL 数据库的权限。
grant all privileges on testdb to dba@’localhost’
其中,关键字 “privileges” 可以省略。
四、grant 高级 DBA 管理 MySQL 中所有数据库的权限。
grant all on *.* to dba@’localhost’
五、MySQL grant 权限,分别可以作用在多个层次上。
1. grant 作用在整个 MySQL 服务器上:
grant select on *.* to dba@localhost; — dba 可以查询 MySQL 中所有数据库中的表。
grant all    on *.* to dba@localhost; — dba 可以管理 MySQL 中的所有数据库
2. grant 作用在单个数据库上:
grant select on testdb.* to dba@localhost; — dba 可以查询 testdb 中的表。
3. grant 作用在单个数据表上:
grant select, insert, update, delete on testdb.orders to dba@localhost;
4. grant 作用在表中的列上:
grant select(id, se, rank) on testdb.apache_log to dba@localhost;
5. grant 作用在存储过程、函数上:
grant execute on procedure testdb.pr_add to ‘dba’@'localhost’
grant execute on function testdb.fn_add to ‘dba’@'localhost’
六、查看 MySQL 用户权限
查看当前用户(自己)权限:
show grants;
查看其他 MySQL 用户权限:
show grants for dba@localhost;
七、撤销已经赋予给 MySQL 用户权限的权限。
revoke 跟 grant 的语法差不多,只需要把关键字 “to” 换成 “from” 即可:
grant all on *.* to   dba@localhost;
revoke all on *.* from dba@localhost;
八、MySQL grant、revoke 用户权限注意事项
1. grant, revoke 用户权限后,该用户只有重新连接 MySQL 数据库,权限才能生效。
2. 如果想让授权的用户,也可以将这些权限 grant 给其他用户,需要选项 “grant option“
grant select on testdb.* to dba@localhost with grant option;
这个特性一般用不到。实际中,数据库权限最好由 DBA 来统一管理。
Category: Post
You can follow any responses to this entry via RSS.
Comments are currently closed, but you can trackback from your own site.
=========================================================================
 
1.创建用户并授权
grant语句的语法:
grant privileges (columns) on what to user identified by "password" with grant option 
要使用该句型,需确定字段有:
privileges 权限指定符权限允许的操作
alter 修改表和索引
create 创建数据库和表
delete 删除表中已有的记录
drop 抛弃(删除)数据库和表
index 创建或抛弃索引
insert 向表中插入新行
reference 未用
select 检索表中的记录
update 修改现存表记录
file 读或写服务器上的文件
process 查看服务器中执行的线程信息或杀死线程
reload 重载授权表或清空日志、主机缓存或表缓存。
shutdown 关闭服务器
all 所有;all privileges同义词
usage 特殊的“无权限”权限
以上权限分三组:
第一组:适用于数据库、表和列如:alter create delete drop index insert select update
第二组:数管理权限 它们允许用户影响服务器的操作 需严格地授权 如:file process reload shut*
第三组:权限特殊 all意味着“所有权限” uasge意味着无权限,即创建用户,但不授予权限
columns
  权限运用的列(可选)并且你只能设置列特定的权限。如果命令有多于一个列,应该用逗号分开它们。
what
  权限运用的级别。权限可以是全局,定数据库或特定表.
user
  权限授予的用户,由一个用户名和主机名组成,许两个同名用户从不同地方连接.缺省:mysql用户password
  赋予用户的口令(可选),如果你对用户没有指定identified by子句,该用户口令不变.
用identified by时,口令字符串用改用口令的字面含义,grant将为你编码口令.
注:set password使用password()函数
with grant option
用户可以授予权限通过grant语句授权给其它用户(可选)
 
实例讲解:
grant all on db_book.* to huaying@koowo.com identified by "yeelion" 只能在本地连接
grant all on db_book.* to huaying@vpn.koowo.com identified by "yeeliong" 允许从此域连接
grant all on db_book.* to huaying@% identified by "yeelion" 允许从任何主机连接
注:"%"字符起通配符作用,与like模式匹配的含义相同。
grant all on db_book.* to huaying@%.koowo.com identified by "yeelion";
允许huaying从koowo.com域的任何主机连接
grant all on db_book.* to huaying@192.168.1.189 identified by "yeelion"
grant all on db_book.* to huaying@192.168.1.% identified by "yeelion"
grant all on db_book.* to huaying@192.168.1.0/17 identified by "yeelion"
允许从单IP 段IP或一子网IP登陆
注:有时 用户@IP 需用引号 如"huaying@192.168.1.0/17"
grant all on *.* to huaying@localhost identified by "yeelion" with grant option
添加超级用户huaying 可在本地登陆做任何操作.
grant reload on *.* to huaying@localhost identified by "yeelion" 只赋予reload权限
grant all on db_book to huaying@koowo.com indetified by "yeelion" 所有权限
grant select on db_book to huaying@% indetified by "yeelion" 只读权限
grant select,insert,delete,update on db_book to huaying@koowo.com indetified by "yeelion"
只有select,insert,delete,update的权限
grant select on db_book.storybook to huaying@localhost indetified by "yeelion" 只对表
grant update (name) on db_book.storybook to huaying@localhost 只对表的name列 密码不变
grant update (id,name,author) on db_book.storybook to huaying@localhost 只对表的多列
grant all on book.* to ""@koowo.com 允许koowo.com域中的所有用户使用库book
 
grant all on book.* to huaying@%.koowo.com indetified by "yeelion" with grant option
允许huaying对库book所有表的管理员授权.
 
2.撤权并删除用户
revoke的语法类似于grant语句
to用from取代,没有indetifed by和with grant option子句. 如下:
revoke privileges (columns) on what from user
user:必须匹配原来grant语句的你想撤权的用户的user部分。
privileges:不需匹配,可以用grant语句授权,然后用revoke语句只撤销部分权限。
revoke语句只删权限不删用户,撤销了所有权限后user表中用户记录保留,用户仍然可以连接服务器.
要完全删除一个用户必须用一条delete语句明确从user表中删除用户记录:
delete from user where user="huaying"
flush privileges; 重载授权表
注:使用grant和revoke语句时,表自动重载,而你直接修改授权表时不是.

Linux Mysql 权限相关信息 来源于网络的更多相关文章

  1. linux用户权限相关内容查看

    linux用户权限相关内容查看 1   用户信息 创建用户一个名为 webuser 的账号,并填写相应的信息: root@iZ94fabhqhuZ:~# adduser webuser Adding ...

  2. MySQL 权限相关

    # ============================= mysql 权限相关 =====================================================gran ...

  3. Linux系统CPU相关信息查询

    Linux系统CPU相关信息查询 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.lscpu常用参数介绍 1>.查看帮助信息 [root@node105 ~]# lscpu ...

  4. Linux - 用户权限相关命令

    用户权限相关命令 目标 用户 和 权限 的基本概念 用户管理 终端命令 组管理 终端命令 修改权限 终端命令 01. 用户 和 权限 的基本概念 1.1 基本概念 用户 是 Linux 系统工作中重要 ...

  5. Linux的权限属性信息1到10位分别什么意思

    要设置权限,就需要知道文件的一些基本属性和权限的分配规则. 在Linux中,ls命令常用来查看文件的属性,用于显示文件的文件名和相关属性. #ls -l 路径          [ls -l  等价于 ...

  6. linux mysql 权限

    原文地址:http://www.cnblogs.com/eczhou/archive/2012/07/12/2588187.html Linux下mysql新建账号及权限设置 1.权限赋予 说明:my ...

  7. Linux 查看系统相关信息(系统发型版本及内核版本等)

    以下为 Linux 以下信息查看命令,记录以备用 # uname -a # 查看内核/操作系统/CPU信息 # /etc/issue # 查看操作系统版本 # cat /proc/cpuinfo # ...

  8. Linux 文件权限相关知识

    文件权限说明 Linux中的文件能否被访问和工具(程序)无关,和访问的用户身份有关(谁去运行这个程序) 进程的发起者(谁去运行这个程序). 进程的发起者若是文件的所有者: 拥有文件的属主权限 进程的发 ...

  9. linux mysql查看安装信息

    ps -ef|grep mysql root               ?        :: /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mys ...

随机推荐

  1. 编程基础——C/C++,Java,ObjC讨论回调模式

    什么是回调? 因为它是从C开始进入编程世界.术语改只是口.叫习惯了.java里通常叫listener(监听器).C/C++里通常叫callback(回调),ObjC里面叫delegate(托付) 回调 ...

  2. Mac OS温馨提示17:七彩花哨的输入

    OSX Mavericks中国的文字输入功能,色于windows,甚至提供了强大的手写输入功能和语音输入功能,而且发展到如今,已经有非常多种第三方输入法支持Mac了. 一.主要的输入法        ...

  3. cocos2d-x—使用shader使图片背景透明

    这里用shader处理了像素,使黑色背景透明,直接上代码 ShaderSprite.h [cpp] view plaincopyprint? #ifndef __TestShader__ShaderS ...

  4. EF6操作Sqlite数据库的项目兼容性问题

    vs2010无法正确打开2015创建的项目里面操作Sqlite数据库时使用EF6创建的edmx文件(会显示空白)   但是可以正常查询 vs2015无法正确打开2010创建的项目里面操作Sqlite数 ...

  5. POJ 3579- Median

     Description Given N numbers, X1, X2, ... , XN, let us calculate the difference of every pair of n ...

  6. zoj-3792-Romantic Value-最小割+数值转化

    假设不须要求边的个数的话,就是一个裸的最小割问题. 求边的个数就用边的权值记录一下. #include <stdio.h> #include <iostream> #inclu ...

  7. MVC 定义JsonpResult实现跨域请求

    MVC 定义JsonpResult实现跨域请求 1:原理 在js中,XMLHttpRequest是不能请求不同域的数据,但是script标签却可以,所以可以用script标签实现跨域请求.具体是定义一 ...

  8. hdu4419 Colourful Rectangle 12年杭州网络赛 扫描线+线段树

    题意:给定n个矩形,每个矩形有一种颜色,RGB中的一种.相交的部分可能为RG,RB,GB,RGB,问这n个矩形覆盖的面积中,7种颜色的面积分别为多少 思路:把x轴离散化做扫描线,线段树维护一个扫描区间 ...

  9. 军医王-moTestin云测试看好移动医疗行业

    看医生汪谟军:Testin云測在移动医疗产业大有可为 2014/10/21 · Testin · 开发人员訪谈 日常生活可能常常碰到这种情况:突然遇上头疼脑热.小病小痛,去医院又不方便:非常想了解家人 ...

  10. uva 10228 - Star not a Tree?(模拟退火)

    题目链接:uva 10228 - Star not a Tree? 题目大意:给定若干个点,求费马点(距离全部点的距离和最小的点) 解题思路:模拟退火算法,每次向周围尝试性的移动步长,假设发现更长处, ...