[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 664
  • 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?
@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
pillmill
Asked:
pillmill
1 Solution
 
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
 
AntyraelCommented:
What happens if you use -p ""? (two double quotes would be an empty string, right?)
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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