One method that is convenient (but equally insecure) is to use: MYSQL_PWD=xxxxxxxx mysql -u root -e "statement"