Mysql – Server 2012 Scheduled Task CMD thesqldump not doing what is intended

MySQLscheduled-tasktask-schedulerwindows-server-2012

I'm running a batch file to back up some mysql databases on a 2012 webserver. The batch file creates a folder, then runs the following for each db:

mysqldump -u *username* -p*Password* *db_name* > C:\folder&filename-%date:~-2,4%-%date:~-7,2%-%date:~-10,2%.sql

This works fine when I manually run the bath file, however when I run the same batch file in task scheduler I get 0kb databases with no content. The folder is created, as is the xyz.sql files, but thats it.

The exact same script is working fine on my 08 server.

Any ideas? Thanks

Best Answer

Had this a couple of times.

Open up your local security policy > local policies > user right assignment

Go to "Log on as a batch job", add the user account that you are running the scheduled task as and test.

(Better yet, create a service account specific to this task and use this)