4

I am Calling a shell script from mysql UDF function sys_exec :

 SET cmd = CONCAT('cd /home/enablement;sh execute.sh ', CONCAT('1', ' ', '1', ' ', '1'));
SET result = sys_exec(cmd);
SELECT result FROM DUAL; 

But I am getting an error code 32512 in result which is probably of two different users one for mysql and other for linux (for execute.sh script) , can you please guide me the way how can I be able to make mysql user to access execute.sh file while invoking sys_exec function.

Thanks In Adv

2
  • if that's MYSQL it wont work you need to specify your variables, for example: SET @cmd:= CONCAT('cd /home/enablement;sh execute.sh ', CONCAT('1', ' ', '1', ' ', '1')); Commented Oct 12, 2012 at 12:49
  • yes varaiable cmd is declared in the procedure , I know the error is becuase of not accessing the file execute.sh , how can I make this shell script (execute.sh) to be accessiable to mySQL user. Commented Oct 12, 2012 at 13:04

2 Answers 2

3

I know that this post is old but maybe it would help someone
You should do this
$ sudo /etc/init.d/apparmor stop
Because AppArmor limits execution of your UDF function.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you @user1722669. I have been breaking my head for sometime, as sys_exec was always returning 32512. sudo /etc/init.d/apparmor teardown did help!
0

Please don't stop apparmor completely, just enable your use case in apparmor's mysqld profile. For example i need to use redis inside mysql.

$ sudo vim /etc/apparmor.d/usr.sbin.mysqld

Then insert this line at the end

/usr/bin/redis-cli mr,

save the file and reload apparmor

sudo service apparmor reload

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.