Link to home
Start Free TrialLog in
Avatar of pillmill
pillmill

asked on

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

Avatar of Frosty555
Frosty555
Flag of Canada image

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)
Avatar of pillmill
pillmill

ASKER

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.
Avatar of Antyrael
What happens if you use -p ""? (two double quotes would be an empty string, right?)
ASKER CERTIFIED SOLUTION
Avatar of marklogan
marklogan
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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."
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
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...


Thanks