How to transfer data between arduino and mysql data base?
Look up the Firmata library.  It runs over serial which the Arduino manages easily.

You're phased this question strangely .  Databases tend not to execute arbitrary code to control general IO.  That requires other code. You're looking at this architecture:-

[Arduino + Firmata] ------ [Firmata + some code + MySQL] 

The some code can be any general programming language that you like and can get to talk to MySQL, and has a Firmata implementation. 

PS. You might try a direct connection using native transport from something like an MySQL Connector Arduino. I have no persomnal experience of this connector, but give it a bash by all means.

This is really a coding question thought isn't it?