How to force quit an AppleScript script launched from toolbar?

Ok, first off, when you are using AppleScript’s “with administrator privileges” you should not use sudo

Second, you need to send the job into the background if you want the AppleScript to finish.

The easiest way of doing that is to put the command in a shell script, like so:

#!/bin/zsh -f

/usr/local/mysql/support-files/mysql.server start &|

exit 0

(Note the &| at the end of the line. That tells the process to go into the 'background')

Save those 3 lines to a file named something like /usr/local/bin/start-mysql-server.sh and then do

chmod 755 /usr/local/bin/start-mysql-server.sh

to make it executable.

Finally, change your AppleScript to

do shell script "/usr/local/bin/start-mysql-server.sh" with administrator privileges

and it should launch and then the gear should disappear.