The magic is in the _init_completion function which is defined in the bash_completion file of the bash-completion packagebash_completion file of the bash-completion package.
There's no easy way out. If you want sensible fancy completion in bash, install the bash-completion package. Then define a function:
. /etc/bash_completion
_my_mysql () {
local cur prev words cword
_init_completion || return
COMPREPLY=($(compgen -W 'firstdatabase databasetwo etc' "$cur"))
}
complete -F _my_mysql mysql