mysqldump - Access denied for user

command-line, mysql

Solution

You should escape the password using single quotes: `-p'password'`.

The correct command would be:

"mysqldump" -h *******.com -u ******* -p'*****' --databases ******* > "C:\******\_Database\backups\DB_%date:~0,3%.bak"

Problem

When I run the following command from an open windows command shell (Win7), it works fine, and the backup is written to my file system. The MySQL database is on a remote linux server. ``` "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqldump" -h *******.com -u ******* -p***** --databases ******* > "C:\******\_Database\backups\DB_%date:~0,3%.bak" ``` But when I put the same command into a batch file (whatever.bat) and run the bat file (with a "pause" command at the end), I get the error "Got error: 1045: Access denied for user 'me'@'c-24-2-64-138.hsd1.ut.comcast.net' (using password: YES) when trying to connect". Why does it work from inside an open command shell, but not when running from a bat file? How can I make this work?

Original source