• Mysql-udf-http 插件的安装与使用


     

    1. 在Linux系统上安装Mysql-udf-http

    ulimit -SHn 65535
    wget http://curl.haxx.se/download/curl-7.21.1.tar.gz
    tar zxvf curl-7.21.1.tar.gz
    cd curl-7.21.1/
    ./configure --prefix=/usr
    make && make install
    cd ../
    
    echo "/usr/local/webserver/mysql/lib/mysql/" > /etc/ld.so.conf.d/mysql.conf
    /sbin/ldconfig
    wget http://mysql-udf-http.googlecode.com/files/mysql-udf-http-1.0.tar.gz
    tar zxvf mysql-udf-http-1.0.tar.gz
    cd mysql-udf-http-1.0/
    ./configure --prefix=/usr/local/webserver/mysql --with-mysql=/usr/local/webserver/mysql/bin/mysql_config
    make && make install
    cd ../

    2. 通过命令行登陆进入MySQL

    mysql -uroot -proot

    3. 创建MySQL自定义函数

    create function http_get returns string soname 'mysql-udf-http.so';  
    create function http_post returns string soname 'mysql-udf-http.so';  
    create function http_put returns string soname 'mysql-udf-http.so';  
    create function http_delete returns string soname 'mysql-udf-http.so';  

    注意: 在执行上述create操作是,若提示如下错误

    create function http_get returns string soname 'mysql-udf-http.so';ERROR 1127 (HY000): Can't find symbol 'http_get' in library

    如果出现上述错误,原因是 /server/mysql/lib/plugin/mysql-udf-http.so 查看/server/mysql/lib/若存在mysql-udf-http.so.0.0.0则拷贝至plugin目录并更名为mysql-udf-http.so即可

     4. 示例 A:

    /* HTTP GET、POST方式提交关键词“xoyo”到百度移动搜索 */  
    SELECT http_get('http://m.baidu.com/s?word=xoyo&pn=0');  
    SELECT http_post('http://m.baidu.com/s','word=xoyo&pn=0');  
      
    /* 新浪微博开放平台:获取新浪用户ID为103500的最近一条微博内容 */  
    SELECT http_get('http://api.t.sina.com.cn/statuses/user_timeline/103500.json?count=1&source=1561596835') AS data;  
    /* 新浪微博开放平台:发表一条微博 */  
    SELECT http_post('http://your_sina_uid:your_password@api.t.sina.com.cn/statuses/update.xml?source=1561596835', 'status=Thins is sina weibo test information');  
      
    /* Tokyo Tyrant 写入、读取、删除操作 */  
    SELECT http_put('http://192.168.8.34:1978/key', 'This is value');  
    SELECT http_get('http://192.168.8.34:1978/key');  
    SELECT http_delete('http://192.168.8.34:1978/key');  

    本文参照: http://blog.s135.com/mysql-udf-http/2/1/

    现主要从事PHP、Uinx/Linux、C/C++等方面的项目开发。
  • 相关阅读:
    [HDOJ3523]Image copy detection
    [HDOJ3526]Computer Assembling
    Ubuntu12.04 配置步骤
    const 详解
    ubuntu 12.04 源
    函数参数和数据成员同名
    友元
    静态数据 成员和静态函数
    成员指针
    内存泄露
  • 原文地址:https://www.cnblogs.com/lsl8966/p/3384459.html
Copyright © 2020-2023  润新知