Here are the Steps:
STEP 01 : Put code in a Text File
Open up a text editor (vi, nano, emacs) and place your code in it.
Save it as /tmp/mynewcode.sql
STEP 02 : Collect All Databases Names
MYSQLCONN=`-uroot -ppassword`
SQLSTMT="SELECT schema_name FROM information_schema.schemata"
SQLSTMT="${SQLSTMT} WHERE schema_name NOT IN"
SQLSTMT="${SQLSTMT} ('information_schema','performance_schema','mysql')"
mysql ${MYSQLCONN} -ANe"${SQLSTMT}" > /tmp/dbnames.txt
STEP 03 : Load Stored Procedure into every database mentioned in /tmp/dbnames.txt
for DB in `cat /tmp/dbnames.txt` ; do mysql ${MYSQLCONN} -D${DB} < /tmp/mynewcode.sql ; done
STEP 04 : Remove the files you made (OPTIONAL)
rm -f /tmp/dbnames.txt
rm -f /tmp/mynewcode.sql
That’s it.
Give it a Try !!!