mysql --batch -u username -ppasswort -e "Show databases"
This will list all of the databases installed.
--batch : is just a reminder for mysql that it's called noninteractive
-u username : the username or maybe another
-ppassword: the password for the user. There should be no space between password an -p
mysql also has an option to not print the name of the columns but i can't recall it. Check out man mysql