gpt4 book ai didi

mysql - 如何在 Mysql 存储过程中包含一个 .sh(脚本)文件?

转载 作者:行者123 更新时间:2023-11-29 03:11:58 24 4
gpt4 key购买 nike

是否可以在 Mysql 的存储过程中包含脚本文件(.sh 文件)?如果是,那么如何?如果不是,那是为什么?

最佳答案

如@mu is too short 说:

您需要从以下位置安装这些 UDF:http://www.mysqludf.org/lib_mysqludf_sys/index.php
这是下载链接:http://www.mysqludf.org/lib_mysqludf_sys/lib_mysqludf_sys_0.0.3.tar.gz

请注意,您的 shell 命令将以 MySQL 用户的权限运行,而不是以连接到 MySQL 的用户的权限运行。
从安全的角度来看,这可能不是一个好主意。

注意链接中的警告:

A Note of Caution Be very careful in deciding whether you need this function. UDFs are available to all database users - you cannot grant EXECUTE privileges for them. As the commandstring passed to sys_exec can do pretty much everything, exposing the function poses a very real security hazard.

Even for a benign user, it is possible to accidentally do a lot of damage with it. The call will be executed with the privileges of the os user that runs MySQL, so it is entirely feasible to delete MySQL's data directory, or worse.

The function is intended for specialized MySQL applications where one needs extended control over the operating system. Currently, we do not have UDF's for ftp, email and http, and this function can be used to implement such functionality in case it is really necessary (datawarehouse staging areas could be a case in example).

You have been warned! If you don't see the hazard, please don't try to find it; just trust me on this.

If you do decide to use this library in a production environment, make sure that only specific commands can be run and file access is limited by using AppArmor.

关于mysql - 如何在 Mysql 存储过程中包含一个 .sh(脚本)文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6772014/

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