MySQL command to show list of databases on server

you can use the -e option to execute some queries on the command line, EG, to list databases:

 mysql -e “show databases” -uUSER -pPASSWORD

Source