Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mysqldump.exe

Status
Not open for further replies.

Bersani

Programmer
Nov 10, 2011
48
US
I am trying to use mysqldump.exe in a .bat file from Windows but I cannot get the right code

I am using: mysqldump.exe –e –u root -p -h localhost testdb > G:\backup.sql

G: is a drive in the same computer
In what directory do I place this batch file?
What is wrong?
 
Bersani said:
What is wrong?

Until we know what is, or is not happening, it's impossible to say.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
What error are you getting?

Going by the exe extension on mysqldump I'll assume this is happening on Windows in which case I'll also assume your batch file is not located in the same folder as mysqldump so it can't find it.

Of course this is all guess work.

Perhaps if you tell us more about where you are running this and what error you are getting we may be able to help.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
I placed a copy of mysqldump.exe in the data folder.
 
Again, without telling us what error you get or what is happening its going to be very difficult to help.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
I get a command prompt window that opens and closes instantly. I get the file backup.sql with no content (0 ).
 
I get a command prompt window that opens and closes instantly

That is expected behavior. When opening a command prompt window by double clicking a bat file, the window will close when the bat file is done.

Try running the bat file in a command prompt window directly by going to Start, and typing "cmd" (without the quotes) in the search bar and clicking on the cmd icon that comes up.

Then change directory to the location of the bat file and try to run it. This should at least let you see the errors.



----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
I tried but the window closes before I can see the error. I see that there is an error message but it disappears.
 
I finally got to see the error message: "error 1045 access denied for user 'ODBC'@localhost < using password: YES> when trying to connect"

I entered the correct password
 
Again, open a cmd window from the start menu. so it doesn't close.

If you double click the bat file it will close the window. Don't double click the bat file at all.

Open a command Prompt directly. Start->Search "cmd". With that command window open. Use the command prompt commands to navigate to the folder in the window.
i.e.
Code:
C:\> cd foldername [enter]

Then run the bat file in that window:
i.e

Code:
C:\> batfilename.bat [enter]

Running it like this will, prevent the window from closing.








----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 
Have you tried running a test with the password in the command line?





Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum
 
It finally worked. Thank you for your help. It prompts me for the password. Is there a way to avoid the prompt?
mysqldump -u root -p testdb > G:\backup.sql
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top