20101120-HOW TO RUN BINARIES AND USE REGULAR EXPRESSION IN MySQL ® (Only Windows, Because I hate posix)

(Updated 2011-04-06)

I've googled how tu run binaries files from mysql, finally i release this post.

MySql UDF Project is:

http://www.mysqludf.org/lib_mysqludf_preg/index.php


1. Download these files. ( Ypu can compilate this file, however is not practical, therefore i published its win-binaries ).
or

And binaries for regular expressions

2. You have to copy thes files into path:
C:\Program Files\MySQL\MySQL Server 5.1\lib\plugin

3. Run this script.

http://rpbouman.blogspot.com/2007/09/creating-mysql-udfs-with-microsoft.html
DROP FUNCTION IF EXISTS sys_eval;
DROP FUNCTION IF EXISTS sys_exec;
DROP FUNCTION IF EXISTS sys_get;
DROP FUNCTION IF EXISTS sys_set;
 
CREATE FUNCTION sys_eval RETURNS STRING SONAME 'lib_mysqludf_sys.dll';
CREATE FUNCTION sys_exec RETURNS STRING SONAME 'lib_mysqludf_sys.dll';
CREATE FUNCTION sys_get  RETURNS STRING SONAME 'lib_mysqludf_sys.dll';
CREATE FUNCTION sys_set  RETURNS STRING SONAME 'lib_mysqludf_sys.dll';
 
DROP FUNCTION IF EXISTS preg_capture;
DROP FUNCTION IF EXISTS preg_check;
DROP FUNCTION IF EXISTS preg_position;
DROP FUNCTION IF EXISTS preg_replace;
DROP FUNCTION IF EXISTS preg_rlike;
DROP FUNCTION IF EXISTS lib_mysqludf_preg_info;
 
CREATE FUNCTION preg_capture            RETURNS STRING SONAME 'lib_mysqludf_preg.dll';
CREATE FUNCTION preg_check              RETURNS STRING SONAME 'lib_mysqludf_preg.dll';
CREATE FUNCTION preg_position           RETURNS STRING SONAME 'lib_mysqludf_preg.dll';
CREATE FUNCTION preg_replace            RETURNS STRING SONAME 'lib_mysqludf_preg.dll';
CREATE FUNCTION preg_rlike              RETURNS STRING SONAME 'lib_mysqludf_preg.dll';
CREATE FUNCTION lib_mysqludf_preg_info  RETURNS STRING SONAME 'lib_mysqludf_preg.dll';
 

4. Example, run this sentence.
SELECT sys_exec('dir > c:\\out.txt') FROM dual

5. Troubleshotting.
In C:\Program Files\MySQL\MySQL Server 5.1 you can see my.ini

You have to configure the plugin_dir
**plugin_dir="C:\\Program Files\\MySQL\\MySQL Server 5.1\\lib\\plugin"**
basedir="C:/Program Files/MySQL/MySQL Server 5.1"
datadir="C:/ProgramData/MySQL/MySQL Server 5.1/Data"
Restart MySql Services
net stop mysql
net start mysql
Finally, you must execute
Show Variables