Your problem is that you're trying to execute mysqldump
from the mysql
CLI.
mysql> mysqldump ... ^^^^^^
First exit mysql
mysql> exit Bye username$
and then in the command prompt start mysqldump
on its own
$ mysqldump -uusername -p"password" --opt dbname > filename.sql;