windows batch set null?

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

pillmillAsked:
Who is Participating?
 
markloganCommented:
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
 
Frosty555Commented:
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
 
pillmillAuthor Commented:
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
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
AntyraelICT SpecialistCommented:
What happens if you use -p ""? (two double quotes would be an empty string, right?)
0
 
markloganCommented:
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
 
Steve KnightIT ConsultancyCommented:
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
 
dacaseyCommented:
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
 
pillmillAuthor Commented:
Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.