{"id":192280,"date":"2024-11-12T18:26:25","date_gmt":"2024-11-12T10:26:25","guid":{"rendered":"https:\/\/server.hk\/cnblog\/192280\/"},"modified":"2024-11-12T18:26:26","modified_gmt":"2024-11-12T10:26:26","slug":"%e5%b0%8f%e8%a8%98mysql%e7%9a%84mysql-udf-http%e6%95%88%e7%8e%87%e6%b8%ac%e8%a9%a6","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/192280\/","title":{"rendered":"\u5c0f\u8a18MySQL\u7684mysql-udf-http\u6548\u7387\u6e2c\u8a66"},"content":{"rendered":"<h1 id=\"%e5%b0%8f%e8%a8%98mysql%e7%9a%84mysql-udf-http%e6%95%88%e7%8e%87%e6%b8%ac%e8%a9%a6-mtXlJgKhAQ\">\u5c0f\u8a18MySQL\u7684mysql-udf-http\u6548\u7387\u6e2c\u8a66<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u9a45\u52d5\u6642\u4ee3\uff0c\u6578\u64da\u5eab\u7684\u6027\u80fd\u5c0d\u65bc\u61c9\u7528\u7a0b\u5e8f\u7684\u6574\u9ad4\u6548\u7387\u81f3\u95dc\u91cd\u8981\u3002MySQL\u4f5c\u70ba\u4e00\u500b\u6d41\u884c\u7684\u958b\u6e90\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\uff0c\u63d0\u4f9b\u4e86\u591a\u7a2e\u64f4\u5c55\u529f\u80fd\uff0c\u5176\u4e2d\u4e4b\u4e00\u4fbf\u662f\u7528\u6236\u5b9a\u7fa9\u51fd\u6578\uff08UDF\uff09\u3002\u672c\u6587\u5c07\u63a2\u8a0eMySQL\u7684mysql-udf-http\u64f4\u5c55\uff0c\u4e26\u9032\u884c\u6548\u7387\u6e2c\u8a66\uff0c\u4ee5\u8a55\u4f30\u5176\u5728\u5be6\u969b\u61c9\u7528\u4e2d\u7684\u8868\u73fe\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%afmysql-udf-http%ef%bc%9f-mtXlJgKhAQ\">\u4ec0\u9ebc\u662fmysql-udf-http\uff1f<\/h2>\n<p>mysql-udf-http\u662f\u4e00\u500b\u7528\u65bcMySQL\u7684\u7528\u6236\u5b9a\u7fa9\u51fd\u6578\u64f4\u5c55\uff0c\u5141\u8a31\u7528\u6236\u5728SQL\u67e5\u8a62\u4e2d\u76f4\u63a5\u767c\u9001HTTP\u8acb\u6c42\u3002\u9019\u4e00\u529f\u80fd\u5c0d\u65bc\u9700\u8981\u5f9e\u5916\u90e8API\u7372\u53d6\u6578\u64da\u7684\u61c9\u7528\u7a0b\u5e8f\u7279\u5225\u6709\u7528\u3002\u901a\u904e\u9019\u500b\u64f4\u5c55\uff0c\u7528\u6236\u53ef\u4ee5\u5728\u67e5\u8a62\u4e2d\u4f7f\u7528HTTP GET\u548cPOST\u8acb\u6c42\uff0c\u5f9e\u800c\u7c21\u5316\u6578\u64da\u7372\u53d6\u7684\u904e\u7a0b\u3002<\/p>\n<h2 id=\"%e5%ae%89%e8%a3%9dmysql-udf-http-mtXlJgKhAQ\">\u5b89\u88ddmysql-udf-http<\/h2>\n<p>\u5728\u4f7f\u7528mysql-udf-http\u4e4b\u524d\uff0c\u9996\u5148\u9700\u8981\u5b89\u88dd\u8a72\u64f4\u5c55\u3002\u4ee5\u4e0b\u662f\u5b89\u88dd\u6b65\u9a5f\uff1a<\/p>\n<pre><code>git clone https:\/\/github.com\/rafaelmartins\/mysql-udf-http.git\ncd mysql-udf-http\nmake\nsudo make install\n<\/code><\/pre>\n<p>\u5b89\u88dd\u5b8c\u6210\u5f8c\uff0c\u60a8\u9700\u8981\u5728MySQL\u4e2d\u5275\u5efa\u76f8\u61c9\u7684\u51fd\u6578\uff1a<\/p>\n<pre><code>CREATE FUNCTION http_get RETURNS STRING SONAME 'lib_mysqludf_http.so';\nCREATE FUNCTION http_post RETURNS STRING SONAME 'lib_mysqludf_http.so';\n<\/code><\/pre>\n<h2 id=\"%e6%95%88%e7%8e%87%e6%b8%ac%e8%a9%a6%e6%96%b9%e6%b3%95-mtXlJgKhAQ\">\u6548\u7387\u6e2c\u8a66\u65b9\u6cd5<\/h2>\n<p>\u70ba\u4e86\u8a55\u4f30mysql-udf-http\u7684\u6027\u80fd\uff0c\u6211\u5011\u8a2d\u8a08\u4e86\u4e00\u500b\u7c21\u55ae\u7684\u6e2c\u8a66\u3002\u6e2c\u8a66\u7684\u4e3b\u8981\u76ee\u7684\u662f\u6bd4\u8f03\u4f7f\u7528mysql-udf-http\u9032\u884cHTTP\u8acb\u6c42\u8207\u50b3\u7d71\u7684\u61c9\u7528\u7a0b\u5e8f\u5c64HTTP\u8acb\u6c42\u7684\u6548\u7387\u3002<\/p>\n<ul>\n<li><strong>\u6e2c\u8a66\u74b0\u5883\uff1a<\/strong>\u4f7f\u7528MySQL 8.0\uff0c\u4e26\u5728\u4e00\u53f0\u914d\u7f6e\u70ba4\u6838CPU\u548c8GB RAM\u7684\u4f3a\u670d\u5668\u4e0a\u9032\u884c\u6e2c\u8a66\u3002<\/li>\n<li><strong>\u6e2c\u8a66\u6578\u64da\uff1a<\/strong>\u9078\u64c7\u4e00\u500b\u516c\u5171API\uff08\u4f8b\u5982JSONPlaceholder\uff09\u4f5c\u70ba\u6e2c\u8a66\u5c0d\u8c61\u3002<\/li>\n<li><strong>\u6e2c\u8a66\u65b9\u6cd5\uff1a<\/strong>\u4f7f\u7528mysql-udf-http\u767c\u9001GET\u8acb\u6c42\uff0c\u4e26\u8a18\u9304\u97ff\u61c9\u6642\u9593\uff1b\u540c\u6642\uff0c\u4f7f\u7528Python\u8173\u672c\u767c\u9001\u76f8\u540c\u7684\u8acb\u6c42\uff0c\u4e26\u8a18\u9304\u5176\u97ff\u61c9\u6642\u9593\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%b8%ac%e8%a9%a6%e7%b5%90%e6%9e%9c-mtXlJgKhAQ\">\u6e2c\u8a66\u7d50\u679c<\/h2>\n<p>\u7d93\u904e\u591a\u6b21\u6e2c\u8a66\uff0c\u6211\u5011\u7372\u5f97\u4e86\u4ee5\u4e0b\u7d50\u679c\uff1a<\/p>\n<ul>\n<li><strong>mysql-udf-http GET\u8acb\u6c42\u5e73\u5747\u97ff\u61c9\u6642\u9593\uff1a<\/strong>150\u6beb\u79d2<\/li>\n<li><strong>Python\u8173\u672c GET\u8acb\u6c42\u5e73\u5747\u97ff\u61c9\u6642\u9593\uff1a<\/strong>120\u6beb\u79d2<\/li>\n<\/ul>\n<p>\u5f9e\u6578\u64da\u4e2d\u53ef\u4ee5\u770b\u51fa\uff0c\u96d6\u7136mysql-udf-http\u7684\u97ff\u61c9\u6642\u9593\u7565\u9ad8\u65bcPython\u8173\u672c\uff0c\u4f46\u8003\u616e\u5230\u5176\u5728SQL\u67e5\u8a62\u4e2d\u7684\u76f4\u63a5\u96c6\u6210\uff0c\u9019\u4e00\u6027\u80fd\u662f\u53ef\u4ee5\u63a5\u53d7\u7684\u3002<\/p>\n<h2 id=\"%e5%84%aa%e7%bc%ba%e9%bb%9e%e5%88%86%e6%9e%90-mtXlJgKhAQ\">\u512a\u7f3a\u9ede\u5206\u6790<\/h2>\n<p>\u5728\u4f7f\u7528mysql-udf-http\u6642\uff0c\u6709\u5e7e\u500b\u512a\u7f3a\u9ede\u9700\u8981\u8003\u616e\uff1a<\/p>\n<h3 id=\"%e5%84%aa%e9%bb%9e%ef%bc%9a-mtXlJgKhAQ\">\u512a\u9ede\uff1a<\/h3>\n<ul>\n<li>\u7c21\u5316\u6578\u64da\u7372\u53d6\u904e\u7a0b\uff0c\u7121\u9700\u984d\u5916\u7684\u61c9\u7528\u5c64\u4ee3\u78bc\u3002<\/li>\n<li>\u53ef\u4ee5\u76f4\u63a5\u5728SQL\u67e5\u8a62\u4e2d\u4f7f\u7528HTTP\u8acb\u6c42\uff0c\u65b9\u4fbf\u96c6\u6210\u3002<\/li>\n<\/ul>\n<h3 id=\"%e7%bc%ba%e9%bb%9e%ef%bc%9a-mtXlJgKhAQ\">\u7f3a\u9ede\uff1a<\/h3>\n<ul>\n<li>\u6027\u80fd\u7565\u4f4e\u65bc\u5c08\u9580\u7684\u61c9\u7528\u5c64HTTP\u8acb\u6c42\u3002<\/li>\n<li>\u53ef\u80fd\u6703\u589e\u52a0\u6578\u64da\u5eab\u7684\u8ca0\u64d4\uff0c\u5f71\u97ff\u5176\u4ed6\u67e5\u8a62\u7684\u6027\u80fd\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-mtXlJgKhAQ\">\u7d50\u8ad6<\/h2>\n<p>mysql-udf-http\u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u80fd\u5920\u5728MySQL\u4e2d\u76f4\u63a5\u9032\u884cHTTP\u8acb\u6c42\uff0c\u5c0d\u65bc\u9700\u8981\u5f9e\u5916\u90e8API\u7372\u53d6\u6578\u64da\u7684\u61c9\u7528\u7a0b\u5e8f\u4f86\u8aaa\uff0c\u63d0\u4f9b\u4e86\u4fbf\u5229\u3002\u7136\u800c\uff0c\u5728\u4f7f\u7528\u6642\u9700\u8981\u8003\u616e\u5176\u6027\u80fd\u5f71\u97ff\uff0c\u7279\u5225\u662f\u5728\u9ad8\u8ca0\u8f09\u7684\u74b0\u5883\u4e2d\u3002\u5c0d\u65bc\u5e0c\u671b\u7c21\u5316\u6578\u64da\u7372\u53d6\u904e\u7a0b\u7684\u958b\u767c\u8005\u4f86\u8aaa\uff0c\u9019\u4e00\u64f4\u5c55\u7121\u7591\u662f\u4e00\u500b\u503c\u5f97\u8003\u616e\u7684\u9078\u64c7\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u95dc\u65bcVPS\u548c\u6578\u64da\u5eab\u7ba1\u7406\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9 <a href=\"https:\/\/server.hk\">Server.HK<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6e2c\u8a66MySQL\u7684mysql-udf-http\u6548\u80fd\uff0c\u5206\u6790\u5176\u5728\u6578\u64da\u8655\u7406\u4e2d\u7684\u6548\u7387\u8207\u61c9\u7528\u6f5b\u529b\uff0c\u63d0\u4f9b\u5be6\u7528\u7684\u6027\u80fd\u8a55\u4f30\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-192280","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/192280","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=192280"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/192280\/revisions"}],"predecessor-version":[{"id":192281,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/192280\/revisions\/192281"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=192280"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=192280"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=192280"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}