Solved

windows batch set null?

Posted on 2010-11-09
8
651 Views
Last Modified: 2012-05-10
I want to execute a mysqldump command with the password set to a null value
using the attached code.

It will run interactively, putting in a carriage return for the password,
but I can't get the batch file to work.

How can I fix this?
@ECHO OFF
CLS
ECHO.

set pass=

C:\wamp\bin\mysql\mysql5.1.36\bin\mysqldump -u user -p %pass%  test > dump.sql

ECHO.
ECHO Finished.

Open in new window

0
Comment
Question by:pillmill
8 Comments
 
LVL 31

Expert Comment

by:Frosty555
ID: 34096406
Omit the -p parameter entirely and it should connect to the database without a password (provided the user account is setup that way in mysql)
0
 

Author Comment

by:pillmill
ID: 34096456
Thanks. If the -p parameter is omitted, the following error occurs:

"Using password: NO, Access denied"

It will execute correctly when run interactively, with a carriage return for password.
0
 
LVL 4

Expert Comment

by:Antyrael
ID: 34096552
What happens if you use -p ""? (two double quotes would be an empty string, right?)
0
 
LVL 7

Accepted Solution

by:
marklogan earned 500 total points
ID: 34096997
Just use

C:\wamp\bin\mysql\mysql5.1.36\bin\mysqldump -u user -p  test > dump.sql

and you should be prompted to type the password in.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 7

Expert Comment

by:marklogan
ID: 34097008
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

"The password to use when connecting to the server. If you use the short option form (-p), you cannot have a space between the option and the password. If you omit the password value following the --password or -p option on the command line, mysqldump prompts for one."
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 34097716
Not familiar with this sql command it but if it waits for a password from a command prompt as opposed to a pop up window then you could try piping one into the program:

echo.|c:\wamp\bin\mysql\mysql5.1.36\bin\mysqldump -u user -p  test > dump.sql

(or whatever you need to do for the password prompt to appear)

Steve
0
 
LVL 5

Expert Comment

by:dacasey
ID: 34104116
You can remove the password from the server

mysqladmin -u root -p password ”

Once executed you should be able to connect using that username and no password.

I'll leave out the security chat...


0
 

Author Closing Comment

by:pillmill
ID: 34104456
Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now