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
In my case, I could access correctly with mysql.exe but not with mysqldump.exe.
mysql.exe
mysqldump.exe
The problem was the port for my connection was not the default one (3306) and I had to put the mysqldump port work with (-P3307)
mysqldump -u root -p -P3307 my_database > /path/backup_database