是否可以在 mysql 触发器中调用 web url(http://)?

发布于 2024-10-15 19:24:23 字数 152 浏览 0 评论 0原文

是否可以从 mysql 触发器调用 web url?

例如:我为插入创建了一个触发器。当时,我想调用一个像 http://www.example.com/ 这样的网址。

Is it possible to call a web url from mysql trigger?

for example: I created a trigger for on insert. At that time, I want call a web url like http://www.example.com/.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

瑕疵 2024-10-22 19:24:23

不直接 - 你必须创建一个用户定义函数 并将其挂钩。

PS:这听起来像是一种使用数据库的糟糕方式。

Not directly -- you have to create a user-defined function and hook it in.

P.S.: This sounds like a terrible way to use a database.

久光 2024-10-22 19:24:23

我希望这篇文章对您有用

来源:http://vorachet.blogspot.com/2013/03/how-to-install-mysql-udf-on-centos.html

How to install MySQL UDF on CENTOS
How to install MySQL UDF on CENTOS

Step1. Download the MYSQL UDF at https://github.com/mysqludf/lib_mysqludf_sys

Step2. Run make script
The default make file written by the project owner at step1 does not works for CentOS 64bit
We need a bit customization as follow.
gcc -Wall -m64 -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/lib_mysqludf_sys.so -fPIC

Precondition: Make sure you have MySQL header files. You can prepare the header files using this command.
yum install mysql-devel.x86_64

Step3. Configure plugin dir in /etc/my.cnf
...
[mysqld]
plugin_dir=/var/lib/mysql/plugin
...

NOTES: Do not forget to change directory owner to mysql   
chown mysql: mysql -R /var/lib/mysql/plugin 

Step4. Copy library to plugin dir
 cp /usr/lib/lib_mysqludf_sys.so /var/lib/mysql/plugin

Step5. Restart MYSQL and Execute this SQL statements 

DROP FUNCTION IF EXISTS lib_mysqludf_sys_info;
DROP FUNCTION IF EXISTS sys_get;
DROP FUNCTION IF EXISTS sys_set;
DROP FUNCTION IF EXISTS sys_exec;
DROP FUNCTION IF EXISTS sys_eval;
CREATE FUNCTION lib_mysqludf_sys_info RETURNS string SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_get RETURNS string SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_set RETURNS int SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_eval RETURNS string SONAME 'lib_mysqludf_sys.so'

TESTING:  SELECT sys_exec ('touch /var/lib/mysql/test.txt ')
You should see /var/lib/mysql/test.txt after above statement is executed.

I hope that this article will be useful for you

source: http://vorachet.blogspot.com/2013/03/how-to-install-mysql-udf-on-centos.html

How to install MySQL UDF on CENTOS
How to install MySQL UDF on CENTOS

Step1. Download the MYSQL UDF at https://github.com/mysqludf/lib_mysqludf_sys

Step2. Run make script
The default make file written by the project owner at step1 does not works for CentOS 64bit
We need a bit customization as follow.
gcc -Wall -m64 -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib/lib_mysqludf_sys.so -fPIC

Precondition: Make sure you have MySQL header files. You can prepare the header files using this command.
yum install mysql-devel.x86_64

Step3. Configure plugin dir in /etc/my.cnf
...
[mysqld]
plugin_dir=/var/lib/mysql/plugin
...

NOTES: Do not forget to change directory owner to mysql   
chown mysql: mysql -R /var/lib/mysql/plugin 

Step4. Copy library to plugin dir
 cp /usr/lib/lib_mysqludf_sys.so /var/lib/mysql/plugin

Step5. Restart MYSQL and Execute this SQL statements 

DROP FUNCTION IF EXISTS lib_mysqludf_sys_info;
DROP FUNCTION IF EXISTS sys_get;
DROP FUNCTION IF EXISTS sys_set;
DROP FUNCTION IF EXISTS sys_exec;
DROP FUNCTION IF EXISTS sys_eval;
CREATE FUNCTION lib_mysqludf_sys_info RETURNS string SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_get RETURNS string SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_set RETURNS int SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_exec RETURNS int SONAME 'lib_mysqludf_sys.so';
CREATE FUNCTION sys_eval RETURNS string SONAME 'lib_mysqludf_sys.so'

TESTING:  SELECT sys_exec ('touch /var/lib/mysql/test.txt ')
You should see /var/lib/mysql/test.txt after above statement is executed.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文