mysql -uuser -ppass -e "SELECT 1;"

-e runs query provided as argument.