何时真正需要MySQL中的Flush Privileges? [英] When is Flush Privileges in MySQL really needed?

查看:244
本文介绍了何时真正需要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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆