Solved

windows batch set null?

Posted on 2010-11-09
8
653 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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

948 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

19 Experts available now in Live!

Get 1:1 Help Now