Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlcmd from command-line with sql authentication

SQLCMD uses windows authentication by default. According to the MSDN documentation, you can change it by adding a -U parameter to the command and then the user name.

The problem is with the password. Is there any way to access the sql server if the password is blank?

sqlcmd -U admin
password:

Whenever I try this and just press enter (indicating that the password is an empty string), I get a message saying that the login failed.

Any suggestions? thanks

like image 519
chama Avatar asked Feb 25 '26 12:02

chama


1 Answers

This forum post http://social.msdn.microsoft.com/Forums/en-US/sqlsecurity/thread/15e4a7c0-6547-44e8-9e25-4f14c12570ca implies that sqlcmd does not support empty passwords. The workaround is to use osql.

However the documentation for sqlcmd here suggests you can use a blank password:

"If the -U option is used and the -P option is not used, and the SQLCMDPASSWORD environment variable has not been set, sqlcmd prompts the user for a password. If the -P option is used at the end of the command prompt without a password sqlcmd uses the default password (NULL)."

Hope one of those helps you!

like image 67
James Holland Avatar answered Feb 27 '26 03:02

James Holland



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!