You can add functions through the user-defined function (UDF) interface. User-defined functions are compiled as object files and then added to and removed from the server dynamically
Hope this article is helpful for you
Hope this article is helpful for you
Step1. Download the MYSQL UDF
wget https://github.com/mysqludf/lib_mysqludf_sys/archive/master.zip
unzip master.zip
cd lib_mysqludf_sys-master/
gcc -Wall -m64 -I/usr/include/mysql -I. -shared lib_mysqludf_sys.c -o /usr/lib64/mysql/plugin/lib_mysqludf_sys.so -fPIC
Step2. 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 Step3. Copy library to plugin dir cp /usr/lib/lib_mysqludf_sys.so /var/lib/mysql/plugin Step4. 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' STEP5 TESTING: SELECT sys_exec ('touch /var/lib/mysql/test.txt ') You should see /var/lib/mysql/test.txt after above statement is executed.
No comments:
Post a Comment