MySQL 实现调用外部程序和系统命令

Refer:

http://www.cnblogs.com/yunsicai/p/4080864.html

1) Download lib_mysqludf_sys
    $ git clone https://github.com/mysqludf/lib_mysqludf_sys.git

2) get mysql plugin dir as LIBDIR:

mysql > show variables like 'plugin_dir';

+--------------+--------------------------+
|variable_name |           value          |
+--------------+--------------------------+
| plugin_dir   |  /usr/lib64/mysql/plugin |
+--------------+--------------------------+

3) Modify Makefile as below:  编译64位的so

LIBDIR=/usr/lib64/mysql/plugin

install:
        gcc -m64 -fPIC -Wall -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o $(LIBDIR)/lib_mysqludf_sys.so

4) If need, install:
    $ apt-get install libmysqlclient-dev

5) Compile on the mysql linux server:
    $ sudo make install

    That will generate and copy lib_mysqludf_sys.so into $(LIBDIR)

**********************************************************************************************

或者省去上面的步骤,直接下载:

里面包含了已经编译好的64位 lib_mysqludf_sys.so,只要复制到 plugin_dir 目录下即可。

**********************************************************************************************

6) Install the library 'lib_mysqludf_sys.so' from terminal using following command:
    $ mysql -u root -p??? -h xxx
    mysql> source ./lib_mysqludf_sys.sql

05-08 15:32