首先编写一个实现curl提交的udf,文件名起名为lib_mysqludf_clearcache.c
mysql udf 编写的相关规范可以查看mysql官方手册
http://dev.mysql.com/doc/refman/5.1/zh/extending-mysql.html#adding-functions
#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
#define DLLEXP __declspec(dllexport)
#else
#define DLLEXP
#endif
#ifdef STANDARD
#include <string.h>
#include <stdlib.h>
#include <time.h>
#ifdef __WIN__
typedef unsigned __int64 ulonglong;
typedef __int64 longlong;
#else
typedef unsigned long long ulonglong;
typedef long long longlong;
#endif /*__WIN__*/
#else
#include <my_global.h>
#include <my_sys.h>
#endif
#include <mysql.h>
#include <m_ctype.h>
#include <m_string.h>
#include <stdio.h>
#include <stdlib.h>
#include <curl/curl.h>
#include <ctype.h>
#define DEST_URL "http://www.web.com/"
my_bool clear_cache_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
return 0;
}
void clear_cache_deinit(UDF_INIT *initid)
{
}
char *clear_cache(UDF_INIT *initid, UDF_ARGS *args, char *result, unsigned long *length, char *is_null, char *error)
{
CURL *curl;
CURLcode res;
// 初始化curl
curl = curl_easy_init();
if(curl != NULL)
{
// 设置目标url
curl_easy_setopt(curl,CURLOPT_URL,DEST_URL);
// 输出header头部信息
curl_easy_setopt(curl,CURLOPT_HEADER,0);
// 执行操作
res = curl_easy_perform(curl);
// 执行回收资源
curl_easy_cleanup(curl);
}
return 0;
}
然后编译生成so文件
gcc -I /usr/include/mysql -shared lib_mysqludf_clearcache.c -o lib_mysqludf_clearcache.so -lcurl
第三步把lib_mysqludf_clearcache.so复制到mysql的插件目录
cp lib_mysqludf_clearcache.so /usr/lib/mysql/plugin/
第四步进入mysql
执行
CREATE FUNCTION clear_cache RETURNS INTEGER SONAME 'lib_mysqludf_clearcache.so';
然后执行 select clear_cache()查看自定义函数是否执行成功
分享到:
相关推荐
lib_mysqludf_sys 的win版本dll库
udf mysql c语言代码,欢迎大家使用
CentOS 7.5 64位下编译好的lib_mysqludf_sys.so,源文件在https://download.csdn.net/download/shaynerain/10715798,我博客 中有介绍怎么用
mysql udf提权文件mysql udf提权文件
mysql-udf-http下载 发现很多链接都是链接到谷歌 在这里csdn传一份,方便大家国内下载 谢谢
mysql 系统命令udf,各种平台64位包
压缩包包含win32位/64位以及linux32位/64位的mysql udf 的c语言源码,自行编译
mysqludf库,mysql中调用系统命令的常用插件
MYSQL提权 UDF.dll MYSQL提权 UDF.dll MYSQL提权 UDF.dll MYSQL提权 UDF.dll
MySQL的UDF实质就是一个不需要设置入口点的动态连接库。本文介绍了一个非常简单的易用的调试方法。这一方法直接利用Windows API,语言无关、开发工具无关、项目类型无关,典型的三无调试方法。
mysql-udf-http.c编译此文件之后可使用MySQL中http_post或http_get方法,此处为原文件,需要自行编译,请谨慎下载。备注:如发现此文件编译时缺少文件可自行下载
基于golang实现的mysql udf,其功能实现在于可以直接通过mysql进行get、post请求
UDF库函数将mysql关系数据映射为JSON格式
mysql免杀UDF 提权必不可少神器。必须配备
lib_mysqludf_http http 获取、发布、放置和删除 构建 mingw 版本的 curl (C:\curl-7.41.0) (mingw32-make.exe mingw32) 确保 libcurl.dll 在系统路径中(mysql 运行所在的用户和路径 env) 用于构建 DLL 的 Mingw...
mysql-udf-http
yum install mysqludf-neokylin.x86_64.rpm [root@localhost ~]# find /usr -name lib_mysqludf_sys.so /usr/lib64/mysql/plugin/lib_mysqludf_sys.so
mysql5.7+的版本已经内部支持json,然后很多生产环境的mysql还是5.7以下的版本,但需求中要使用JSON,又不想升级mysql版本,毕竟运行稳定...那如何在5.7以下的版本中使用json呢,下面介绍加入lib_mysqludf_json的方法。
MYSQL_UDF 5.0最新源码,内部包含40个文件,供下载使用
MYSQL的UDF开发的测试程序