This is a tricky one, I have the following output:
mysqldump: Got error: 1045: Access denied for user \'root\'@\'localhost\' (using password: YES) when tr
Don't enter the password with command. Just enter,
mysqldump -u -p > .sql
Then you will get a prompt to enter password.