Basically chuck it inside a .php file fill out the details and run it, it will optimize all the databases under the chosen mysql_user.
You should then setup a new cronjob and set it to run this file on a regular basis (I have mine set to twice a week).
A side note: show database must not be disabled in my.cnf (by default it is on)