7.2.1 MySQL提供的权限

2023-05-16

MySQL提供的权限应用于不同的上下文和不同的操作级别:
- 管理权限使用户可以管理MySQL服务器的操作。这些权限是全局性的,因为它们不是局限于某个特定的数据库
- 数据库权限应用于数据库和数据库的组成对象。这些权限可以被赋权时可以是针对某个数据库的,或者针对所有数据库的。
- 数据库对象(比如表,索引,视图,存储过程,存储方法)权限赋权时可以是针对某个数据库内的特定对象,或者这个数据库内的一个类型的所有对象(比如一个数据库的所有表),或者全局数据库的一个类型的所有对象.
账号权限的信息被保存在mysql数据库中的user, db, tables_priv, columns_priv, and procs_priv表中。
下面的表格展示了在sql级别的grant和revoke语句中的权限名称,以及每个权限在grant表和其应用的上下文中的列名。
Table 7.2 Permissible Privileges for GRANT and REVOKE

PrivilegeColumnContext
CREATECreate_privdatabases, tables, or indexes
DROPDrop_privdatabases, tables, or views
GRANT OPTIONGrant_privdatabases, tables, or stored routines
LOCK TABLESLock_tables_privdatabases
REFERENCESReferences_prdvatabases or tables
EVENTEvent_privdatabases
ALTERAlter_privtables
DELETEDelete_privtables
INDEXIndex_privtables
INSERTInsert_privtables or columns
SELECTSelect_privtables or columns
UPDATEUpdate_privtables or columns
CREATE TEMPORARY TABLESCreate_tmp_table_privtables
TRIGGERTrigger_privtables
CREATE VIEWCreate_view_privviews
SHOW VIEWShow_view_privviews
ALTER ROUTINEAlter_routine_privstored routines
CREATE ROUTINECreate_routine_privstored routines
EXECUTEExecute_privstored routines
FILEFile_privfile access on server host
CREATE TABLESPACECreate_tablespace_privserver administration
CREATE USERCreate_user_privserver administration
PROCESSProcess_privserver administration
PROXYsee proxies_priv tableserver administration
RELOADReload_privserver administration
REPLICATION CLIENTRepl_client_privserver administration
REPLICATION SLAVERepl_slave_privserver administration
SHOW DATABASESShow_db_privserver administration
SHUTDOWNShutdown_privserver administration
SUPERSuper_privserver administration
ALL [PRIVILEGES]server administration
USAGEserver administration

下面的清单大致描述了MySQL中的每个权限。特定的SQL语句可能会有多个权限需。如果是这样的语句,语句的描述中会给出细节说明。

  • ALL or ALL PRIVILEGES权限符合是缩写,表示一个给定级别的所有权限(除了grant选项)。比如,granting ALL at the global or table level 会把赋予所有的全局权限或者所有的表级权限。
  • Alter权限允许使用alter table来改变表结构.alter table同时还需要create和insert权限。重命名一个表需要对旧表有alter和drop权限,同时对新表有create和insert权限。
  • alter或drop存储方法和过程时需要有Alter Routine权限。
  • Create权限允许新建数据库和表。
  • 新建存储过程和方法时需要有Create Routine权限。
  • 新建/修改/丢弃tablespace和日志文件组时需要有Create Tablespace权限。
  • CREATE TEMPORARY TABLES 权限允许使用CREATE TEMPORARY TABLE语句来新建临时表。
    一个会话创建一个临时表后,服务器不再对这个表进行权限检查。The creating session can perform any operation on the table, such as DROP TABLE, INSERT, UPDATE, or SELECT.
    这就意味着即使一个会话的当前用户没有权限创建临时表,该会话也能操作临时.假设当前当前用户没有CREATE TEMPORARY TABLES权限,但是他能够像拥有CREATE TEMPORARY TABLES权限的人一样执行DEFINER-context(定义者上下文)的存储过程来建立一个临时表。当存储执行时,会话使用的是定义者的权限。当存储返回结束后,实际的权限还原到当前用户,这时该用户依然能够看到临时表,并对它进行任何操作。
    为了使临时表和非临时表的权限分开,一个常见的变通方法是为临时表专门建一个数据库。然后一个用户可以被赋予针对这个数据库的CREATE TEMPORARY TABLES权限,也包括这个用户需要的针对临时表的其他权限。
  • CREATE USER权限允许使用ALTER USER, CREATE USER, DROP USER, RENAME USER, 和REVOKE ALL PRIVILEGES.
  • CREATE VIEW权限允许使用CREATE VIEW.
  • DELETE权限允许在一个数据库中将行从表中删除。
  • DROP权限允许你清除存在的数据库/表和试图。DROP权限用来对一个分区表使用ALTER TABLE … DROP PARTITION语句。TRUNCATE TABLE也需要DROP权限。如果你把mysql数据库的DROP权限赋给一个用户,这个用户可以清除掉存储MySQL权限的数据库。
  • EVENT权限用来在事件调度中create, alter, drop, or see events。
  • EXECUTE权限用来执行存储过程和存储函数。
  • FILE权限用来在服务器主机上使用LOAD DATA INFILE and SELECT … INTO OUTFILE 语句和LOAD_FILE()函数读写文件 . A user who has the FILE privilege can read any file on the server host that is either world-readable or readable by the MySQL server. (This implies the user can read any file in any database directory, because the server can access any of those files.) The FILE privilege also enables the user to create new files in any directory where the MySQL server has write access. This includes the server’s data directory containing the files that implement the privilege tables. As a security measure, the server will not overwrite existing files. As of MySQL 5.7.17, the FILE privilege is required to use the DATA DIRECTORY or INDEX DIRECTORY table option for the CREATE TABLE statement.
  • To limit the location in which files can be read and written, set the secure_file_priv system to a specific directory. See Section 6.1.5, “Server System Varia”.
  • The GRANT OPTION privilege enables you to give to other users or remove from other users those privileges that you yourself possess.
  • The INDEX privilege enables you to create or drop (remove) indexes. INDEX applies to existing tables. If you have the CREATE privilege for a table, you can include index definitions in the CREATE TABLE statement.
  • The INSERT privilege enables rows to be inserted into tables in a database. INSERT is also required for the ANALYZE TABLE, OPTIMIZE TABLE, and REPAIR TABLE table-maintenance statements.
  • LOCK TABLES权限允许使用明确的LOCK TABLES语句来锁住你有SELECT权限的表。这包括写锁,以防止其他会话读取这个表。
  • PROCESS权限是关于展示在服务器中执行的线程的信息(即会话执行的语句的信息)。这个权限允许使用SHOW PROCESSLIST或mysqladmin processlist来查看属于其他账号的线程;你也可以查看你自己的线程。PROCESS权限也能使用SHOW ENGINE.
  • PROXY权限允许一个用户模仿或者被视为另一个用户。详情见7.3.9-Proxy Users.
  • The REFERENCES privilege is unused before MySQL 5.7.6. As of 5.7.6, creation of a foreign key constraint requires the REFERENCES privilege for the parent table.
  • The RELOAD privilege enables use of the FLUSH statement. It also enables mysqladmin commands that are equivalent to FLUSH operations: flush-hosts, flush-logs, flush-privileges, flush-status, flush-tables, flush-threads, refresh, and reload.
    The reload command tells the server to reload the grant tables into memory. flush-privileges is a synonym for reload. The refresh command closes and reopens the log files and flushes all tables. The other flush-xxx commands perform functions similar to refresh, but are more specific and may be preferable in some instances. For example, if you want to flush just the log files, flush-logs is a better choice than refresh.
  • The REPLICATION CLIENT privilege enables the use of SHOW MASTER STATUS, SHOW SLAVE STATUS, and SHOW BINARY LOGS.
  • The REPLICATION SLAVE privilege should be granted to accounts that are used by slave servers to connect to the current server as their master. Without this privilege, the slave cannot request updates that have been made to databases on the master server.
  • SELECT权限使你能够从一个数据库的表中选择行。SELECT语句只有在真正从表中检索行时才需要。有一些SELECT语句不访问表,可以不需要Select权限就可以执行。比如,你可以使用select作为一个简单的计算器来计算那些不引用表的表达式:
    SELECT 1+1;
    SELECT PI()*2;

    对于一些读取列内容的语句时,SELECT权限也是必须的,比如在update语句右边col_name=expr表达式中引用的列,或在delete/update语句where分句中提到的列。
  • SHOW DATABASES权限使用户能够通过发送SHOW DATABASES语句来查看数据库名称。 Accounts that do not have this privilege see only databases for which they have some privileges, and cannot use the statement at all if the server was started with the –skip-show-database option. Note that any global privilege is a privilege for the database.
  • SHOW VIEW权限允许使用SHOW CREATE VIEW语句。
  • The SHUTDOWN privilege enables use of the SHUTDOWN statement, the mysqladmin shutdown command, and the mysql_shutdown() C API function.
  • The SUPER privilege enables these operations and server

    • Enable use of the PURGE BINARY LOGS statement.
    • Enable use of the CHANGE MASTER TO and CHANGE REPLICATION FILTER s
    • Enable use of the KILL statement or mysqladmin kill command to kill threads belonging to other accounts. (You can always kill your own threads.)
    • Enable use of the BINLOG statement.
    • Enable use of the CREATE SERVER, ALTER SERVER, and DROP SERVER statements.
    • Enable use of the mysqladmin debug command.
    • Enable starting and stopping replication on slave servers, including Group Replication.
    • Enable configuration changes by modifying global system variables. For some system variables, setting the session value also requires the SUPER privilege; if so, it is indicated in the variable description. Examples include binlog_format, sql_log_bin, and sql_log_off.
    • Enable performing updates even when the read_only system variable is enabled. This applies to table updates and use of account-management statements such as GRANT and REVOKE.
    • Enable specifying any account in the DEFINER attribute of stored programs and views.
    • Enable execution of Version Tokens user-defined functions.
    • Enable InnoDB key rotation.
    • Enable reading the DES key file by the DES_ENCRYPT() function.
    • The server accepts one connection from a SUPER client even if the connection limit controlled by the max_connections system variable is reached.
    • The server does not execute init_connect system variable content when SUPER clients connect.
    • A server in offline mode does not terminate SUPER client connections at the next client request, and accepts new connections from SUPER clients.
      You may also need the SUPER privilege to create or alter stored functions if binary logging is enabled, as described in Section 22.7, “Binary Logging of Stored Programs”.
      The TRIGGER pr
  • The TRIGGER privilege enables trigger operations. You must have this privilege for a table to create, drop, execute, or display triggers for that table.
    When a trigger is activated (by a user who has privileges to execute INSERT, UPDATE, or DELETE statements for the table associated with the trigger), trigger execution requires that the user who defined the trigger still have the TRIGGER privilege.
    The UPDATE pr

  • The UPDATE privilege enables rows to be updated in tables in a database.

  • The USAGE privilege specifier stands for “no privileges.” It is used at the global level with GRANT to modify account attributes such as resource limits or SSL characteristics without affecting existing account privileges.
    It is a good idea to grant to an account only those privileges that it needs. You should exercise particular caution in granting the FILE and administrative privileges:
  • The FILE privilege can be abused to read into a database table any files that the MySQL server can read on the server host. This includes all world-readable files and files in the server’s data directory. The table can then be accessed using SELECT to transfer its contents to the client host.
  • GRANT OPTION权限允许用户将他们拥有的权限付给其他用户。两个拥有不同权限且都有GRANT OPTION权限的用户可以组合权限。
  • ALTER权限可以通过重新命名表来暗中破坏权限系统。
  • SHUTDOWN权限可以被滥用于通过关闭服务器来完全拒绝服务其他人。
  • The PROCESS privilege can be used to view the plain text of currently executing statements, including statements that set or change passwords.
  • SUPER权限可以用来中断其他会话或者改变服务器运作的方式。
  • Privileges granted for the mysql database itself can be used to change passwords and other access privilege information. Passwords are stored encrypted, so a malicious user cannot simply read them to know the plain text password. However, a user with write access to the user table authentication_string column can change an account’s password, and then connect to the MySQL server using that account.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

7.2.1 MySQL提供的权限 的相关文章

  • 我可以使用 HSQLDB 进行 junit 测试克隆 mySQL 数据库吗

    我正在开发一个 spring webflow 项目 我想我可以使用 HSQLDB 而不是 mysql 进行 junit 测试吗 如何将我的 mysql 数据库克隆到 HSQLDB 如果您使用 spring 3 1 或更高版本 您可以使用 s
  • 在mysql中的单个查询中更新多个表

    我有三个查询 我想要一个 这是我的查询 UPDATE tab1 SET a WHERE id 3 UPDATE tab2 SET b WHERE id 9 UPDATE tab3 SET c WHERE id 5 您可以尝试下面的代码 UP
  • 连接 Netbeans 和 MySQL 但出现大整数错误

    所以我正在尝试向我的 Netbeans 数据库 即 MySQL 添加新连接 但我遇到了大整数转换错误 有人可以帮助我吗 详细地 我右键单击现有的MySQL 服务器位于 localhost 3306 root 已断开连接 gt gt 选择co
  • Windows 8.1 升级后 Apache 无法工作 [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 今天从 Windows 8 升级到 Windows 8 1 后 Apache 不再工作 我上次从 Windows 7 升级到 Window
  • MySql 5.7 ORDER BY 子句不在 GROUP BY 子句中并且包含非聚合列

    我试图在不禁用 my ini 中的 only full group by 的情况下弄清楚 这是我的查询 SELECT p title COUNT t qty AS total FROM payments t LEFT JOIN produc
  • MySQL 8 用逗号分割字符串并将其转换为JSON ARRAY

    我有以下字符串 a b c d 我想将它转换成一个 json 数组 像这样 a b c d MySQL 8 有什么函数可以实现这个功能吗 Try SELECT CAST CONCAT REPLACE a b c d AS JSON See
  • MySQL“LIKE”搜索不起作用

    我通过 LOAD DATA INFILE 在 MySQL 中导入了一个 txt 数据库 一切似乎都正常 唯一的问题是 如果我使用以下查询在数据库上搜索记录 SELECT FROM hobby WHERE name LIKE Beading
  • Google Cloud SQL 在重新启动时卡住

    我的云 sql 实例长时间处于重新启动状态 在操作窗格中 重新启动的状态显示为待处理 并且还发生了导出 其状态仍为Running 有没有办法可以强制重新启动或取消重新启动或从常规备份中恢复数据 不 没有办法 如果您向 Google 支付高级
  • 即使没有结果也返回一个值

    我有这种简单的查询 它返回给定 id 的非空整数字段 SELECT field1 FROM table WHERE id 123 LIMIT 1 问题是如果找不到 id 结果集就是空的 我需要查询始终返回一个值 即使没有结果 我有这个东西工
  • mysql转储到derby

    我正在使用 derby 在 eclipse 中进行开发 是否可以从 MySQL 转储表并以某种方式将其用于 derby 我知道 ddl 和 dml 对于两个 dbms 来说是不同的 但我正在寻找一种除了转储 导出之外的合适方法 我可以找到两
  • PHP PDO 使用 bindParam 第一个参数(不带冒号)[重复]

    这个问题在这里已经有答案了 请检查这个 user id int GET user id sql DELETE FROM users WHERE user id user id query db gt prepare sql query gt
  • 每月获取记录,但如果该月没有记录,则为零

    如果我有以下 SQL 表 Tests id type receiveDate 1 Blood 2012 01 18 2 Blood 2012 01 20 3 Blood 2012 01 18 4 Blood 2012 03 01 5 Blo
  • 慢速自动增量重置

    我有很多表 由于某些原因 我需要在应用程序启动时调整这些表的自动增量值 我尝试这样做 mysql gt select max id from item max id 97972232 1 row in set 0 05 sec mysql
  • 如何在 SEQUELIZE (nodeJS) 中创建触发器?

    我正在尝试使用sequelize 创建一个触发器 主要思想是创建一个实例CONFIG创建后USER USER MODEL module exports function sequelize DataTypes var User sequel
  • PHP MySql 百分比

    我的问题是关于百分比 我不是专家 所以我会尽力以更好的方式进行解释 我的 mysql 服务器中有一个表 假设有 700 条记录 如下所示 Name country language Birth Lucy UK EN 1980 Mari Ca
  • 将庞大数据库从亚马逊RDS导出到本地mysql

    我在 Amazon RDS 上有一个 mysql 数据库 大约 600GB 数据 我需要将其移回本地专用服务器 但我不知道从哪里开始 每次我尝试初始化 sqldump 时它都会冻结 有没有办法将其移至 S3 甚至可能在开始下载之前将其分成更
  • 如何通过Elasticsearch模糊匹配电子邮件或电话?

    我想通过 Elasticsearch 对电子邮件或电话进行模糊匹配 例如 匹配所有以以下结尾的电子邮件 gmail com or 匹配所有电话开头136 我知道我可以使用通配符 query wildcard email gmail com
  • mysql自动存储记录创建时间戳

    mysql 有什么方法可以在创建记录时自动将时间戳存储在记录行中 我试图使用时间戳 数据类型 和 current timestamp 作为默认值 但后来意识到每次更新记录时都会更新 我只需要一些可以存储创建时间戳的东西 Thanks Set
  • Mysql插入表后不显示右单引号(’)

    我有一个名为 测试 的表 我插入了一行 其中包含unicode字符右单引号 0x2019在名称字段中 SQL insert into Testing values Sno Name Address insert into Testing v
  • post php mysql 的拆分关键字

    我有一个表存储帖子 ID 它的标签如下 Post id Tags 1 keyword1 keyword2 keyword3 我想循环遍历该表中的每一行并执行以下操作 将关键字1 关键字2 关键字3放入新表中 word id word val

随机推荐

  • OpenCore黑苹果引导开机声音与图形界面设置

    下载最新版本OpenCore与OpenCore Configurator 下载的OpenCore包里面包含了声音与图形所需要的Resources文件夹 Misc Boot下设置 Misc Boot PickerAudioAssist 勾选
  • 在你的硬盘上建立第二个 EFI 分区

    文章目录 隐藏 操作环境 xff1a macOS 群里经常会看到很多小白因为安装双系统导致破坏 EFI 引导分区的事情发生 xff0c 这通常是指Windows和macOS双系统并存的情况 一些台式机友为了彼此系统相安无事 xff0c 就加
  • OpenCore 升级 0.7.2 后引导界面没有 10.15 及以下系统选项的解决办法

    前言 OpenCore 发布了 0 7 2 正式版 xff0c 总体来看这并不是一个大更新 xff0c 属于常规更新 xff0c 但是在安全性方面做了一个不大不小的改动 xff0c 影响了很多用户 OpenCore 0 7 2 针对 mac
  • 黑苹果台式机免驱独显购买推荐

    文章目录 隐藏 macOS big sur 11 4 免驱动独显macOS Mojave macOS Catalina big sur Monterey系统下AMD免驱动独显 xff1a macOS Mojave macOS Catalin
  • 数组中删数(只删一个)

    Description 在给定的数组中删除一个数 Input 多组测试 xff0c 每组第一行输入1个整数n xff08 n lt 20 然后是n个整数 第二行输入1个整数m Output 删除在第一行的n个整数中第一次出现数字m并删除 x
  • 在java中 随机产生10个范围在1~100的随机数放置到数组中,重复的数去掉,使用原生的冒泡排序,然后遍历打印排序后的结果

    在java中 随机产生10个范围在1 100的随机数放置到数组中 xff0c 重复的数去掉 xff0c 使用原生的冒泡排序 xff0c 然后遍历打印排序后的结果 随机范围1 100的随机数 10个 放置到数组中 xff0c 重复的数组去掉
  • java.lang.ClassCastException: class org.apache.logging.slf4j.SLF4JLoggerContext cannot be cast

    spring boot 3 0 0 使用gradle7 6整和myabtis plus 3 5 3 1 出现如下报错 java lang ClassCastException class org apache logging slf4j S
  • java上传图片或者文件到nginx服务器

    红线部分就是Nginx上的路径 注解 64 requiresPermissions这个是权限的问题 可以去掉 千万不要忘了红线部分 这是上传图片 其实上传文件跟这个也是一样的 当然这里面少了一些判断 比如限制文件的大小等 当你完成之后访问你
  • jsp页面的onclick事件

    lt input nclick 61 34 document all WebBrowser ExecWB 1 1 34 type 61 34 button 34 value 61 34 打开 34 name 61 34 Button1 34
  • 位运算abc

    位运算 xff0c 针对单个位进行的运算方式 xff0c 不涉及阶 常见的位运算包括位与 amp 位或 异或 位非 移位 左移 lt lt 和右移 gt gt 等运算 位运算常见的用处有 xff1a 对二进制数指定位置0 xff0c 1取出
  • c混合运算和数据类型转换

    C语言表达式进行混合运算时 xff0c 运算规则 xff1a 运算符相应的数据先做类型统一根据运算变量决定运算精度根据结果变量决定结果精度 其中 xff0c 类型统一时的默认的数据类型转换规则如下图 xff1a
  • oracle-plsql初步使用

    之前使用Oracle数据库都是通过jdbc接口调用oracle 最近由于工作的关系需要通过tns操作Oracle数据库 xff0c 于是把最近学习和收集的一点内容记录下来 xff0c 以便以后再次使用时参考 概念先行概念落地登陆常用sql利
  • ubuntu on win10

    开启大门 设置 安全和更新 针对开发人员 使用开发人员功能 开发人员模式控制面板 程序和功能 启用和关闭windows功能 适用于Linux的windows子系统 xff08 beta xff09 进入cmd命令窗口 xff0c 输入bas
  • Lamp环境搭建和ucenter/ucenterhome

    环境 xff1a Centos 7 3 1611 步骤 xff1a 安装apache php软件 xff1a yum install httpd php php mysql安装mysql mariadb xff0c 以Centos系统为例
  • win10安装系统自带应用

    以管理员身份启动系统自带的Windows Powershell组件 xff0c 接着输入Get AppxPackage allusers Select Name PackageFullName xff0c 通过该命令获取当前系统安装的所有应
  • SQL DDL从MySQL到Oracle

    最新一个项目的sql ddl为MySQL准备的 xff0c 我想在Oracle中使用 之前不太了解两者的区别 xff0c 结果报错一坨 于是顶着头皮开始看什么问题 xff0c 以下是我陷过的坑 xff0c 让大家看看 废话少说 xff0c
  • 7 MySQL安全概述

    1 常见因素 密码 常见的密码要求 xff1a 包含大小写 数字 特殊字符限制 长度 不要保存密码明文 为防止彩虹表 xff0c 也不要简单的使用hash方法 xff0c 可以采用hash hash password 43 salt 的方式
  • 关于SIFT和SURF介绍

    SIFT xff08 尺度不变特征变换 xff09 关于一些角点检测技术 xff0c 比如 Harris 等 它们具有旋转不变特性 xff0c 即使图片发生了旋转 xff0c 我们也能找到同样的角点 xff0c 但如果进行图像缩放 xff0
  • 7.2 MySQL权限系统原理

    MySQL权限系统的用户接口由SQL语句组成 xff0c 比如create user xff0c grant xff0c revoke 在数据库内部 xff0c MySQL把权限信息保存在MySQL database的赋权表中 MySQL服
  • 7.2.1 MySQL提供的权限

    MySQL提供的权限应用于不同的上下文和不同的操作级别 xff1a 管理权限使用户可以管理MySQL服务器的操作 这些权限是全局性的 xff0c 因为它们不是局限于某个特定的数据库 数据库权限应用于数据库和数据库的组成对象 这些权限可以被赋