Learnner Learnner - 17 days ago 9
MySQL Question

windows batch file for mysqldump command

this is first time I am upto making a windows batch file.I wish not to do experiments first as its related to live server.
I use to back up mySql database by following
open cmd
write

mysqldump -u user -p DBname >C:\DBname.sql


then cmd ask password

password = password


I want to make a windows batch file ,upon click I wish to perform the above functionality.
Can any one please give some instructions related script of .bat file

So far I wrote this

ECHO OFF
mysqldump -u user -p DBname >C:\DBname.sql
GO
SET password = password
Go


but still it prompts me for password .
I wish password get enter automatically

Answer

The one-liner:

mysqldump -u user -p DBname --password YOURPASSWORD > C:\DBname.sql

should do it.

Comments