Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 669
  • Last Modified:

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?

set pass=

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

ECHO Finished.

Open in new window

1 Solution
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)
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.
AntyraelICT SpecialistCommented:
What happens if you use -p ""? (two double quotes would be an empty string, right?)
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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.

"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."
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)

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...

pillmillAuthor Commented:
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.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now