gpt4 book ai didi

mysql - 关闭 LOAD DATA INFILE 或 INTO OUTPUT

转载 作者:行者123 更新时间:2023-11-29 08:02:26 28 4
gpt4 key购买 nike

作为一个有安全意识的人,如果发生 SQL 注入(inject),我希望将造成的损害降到最低。其中一种可能性是存在可以读取信息并将信息写入本地文件系统上的文件的查询。在安全漏洞的情况下,这显然是一个主要问题,并且这些命令的使用在日常使用中相当有限。或者,可以将其打开一段隔离的时间,以防我需要导入和导出数据,但我希望在任何其他时间将其显式关闭。我没有通过谷歌搜索或浏览 MySQL 手册找到允许我禁用此选项的特定设置。

我知道我可以轻松地撤销所有用户的权限,但我想要一个更简单的解决方案,默认情况下可以提高我的安全性(至少在这种特定情况下)。

有人知道在 MySQL 中停用任何文件交互的任何设置或方法吗?

谢谢!

最佳答案

http://dev.mysql.com/doc/refman/5.6/en/load-data.html说:

Also, to use LOAD DATA INFILE on server files, you must have the FILE privilege.

http://dev.mysql.com/doc/refman/5.6/en/select-into.html说:

The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host, so you must have the FILE privilege to use this syntax.

您还可以设置secure_file_priv配置变量:

By default, this variable is empty. If set to the name of a directory, it limits the effect of the LOAD_FILE() function and the LOAD DATA and SELECT ... INTO OUTFILE statements to work only with files in that directory.

Percona Server, secure_file_priv还有一个额外的用法:

When used with no argument, the LOAD_FILE() function will always return NULL. The LOAD DATA INFILE and SELECT INTO OUTFILE statements will fail with the following error: “The MySQL server is running with the –secure-file-priv option so it cannot execute this statement”.

关于mysql - 关闭 LOAD DATA INFILE 或 INTO OUTPUT,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23415610/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com