何时真正需要MySQL中的Flush Privileges?

编程入门 行业动态 更新时间:2024-10-26 23:36:01
本文介绍了何时真正需要MySQL中的Flush Privileges?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

在创建新表并与用户一起使用时,我通常只调用以下命令:

When creating new tables and a user to go along with it, I usually just invoke the following commands:

CREATE DATABASE mydb; GRANT ALL PRIVILEGES ON mydb.* TO myuser@localhost IDENTIFIED BY "mypassword";

发出前两个命令后,我再也不需要使用FLUSH PRIVILEGES命令.用户可以登录并使用他们的数据库,并运行可以很好地连接到数据库的PHP脚本.然而,我看到几乎所有我看过的教程都使用了此命令.

I have never ever needed to utilize the FLUSH PRIVILEGES command after issuing the previous two commands. Users can log in and use their database and run PHP scripts which connect to the database just fine. Yet I see this command used in almost every tutorial I look at.

何时真正需要FLUSH PRIVILEGES命令,什么时候不必要?

When is the FLUSH PRIVILEGES command really needed and when is it unnecessary?

推荐答案

通过GRANT选项分配的权限不需要FLUSH PRIVILEGES才能生效-MySQL服务器将注意到这些更改并立即重新加载授权表.

Privileges assigned through GRANT option do not need FLUSH PRIVILEGES to take effect - MySQL server will notice these changes and reload the grant tables immediately.

来自MySQL文档:

如果您直接使用诸如 INSERT,UPDATE或DELETE,您的更改不会影响特权 检查直到您重新启动服务器或告诉它重新加载服务器 桌子.如果您直接更改授权表但忘记重新加载 它们,直到重新启动服务器,您的更改才会生效.这 可能会让您想知道为什么您的更改似乎没有任何作用!

If you modify the grant tables directly using statements such as INSERT, UPDATE, or DELETE, your changes have no effect on privilege checking until you either restart the server or tell it to reload the tables. If you change the grant tables directly but forget to reload them, your changes have no effect until you restart the server. This may leave you wondering why your changes seem to make no difference!

要告诉服务器重新加载授权表,请执行 冲洗特权操作.这可以通过发出FLUSH来完成 PRIVILEGES语句或通过执行mysqladmin flush-privileges或 mysqladmin reload命令.

To tell the server to reload the grant tables, perform a flush-privileges operation. This can be done by issuing a FLUSH PRIVILEGES statement or by executing a mysqladmin flush-privileges or mysqladmin reload command.

如果您使用帐户管理间接修改拨款表 语句,例如GRANT,REVOKE,SET PASSWORD或RENAME USER, 服务器注意到这些更改并将授权表加载到内存中 立即再次.

If you modify the grant tables indirectly using account-management statements such as GRANT, REVOKE, SET PASSWORD, or RENAME USER, the server notices these changes and loads the grant tables into memory again immediately.

更多推荐

何时真正需要MySQL中的Flush Privileges?

本文发布于:2023-11-15 23:10:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1598787.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:MySQL   Flush   Privileges

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!