简体   繁体   English

sqlcmd 的 SQL Server 登录问题

[英]SQL Server login issue with sqlcmd

I am trying to run a file in Ubuntu using the sqlcmd command as shown below.我正在尝试使用sqlcmd命令在 Ubuntu 中运行一个文件,如下所示。 We have a complex password set as per standards.我们按照标准设置了复杂的密码。 Using that I am getting an error saying that "Login failed for the user "username" ".使用它,我收到一条错误消息,指出“用户“用户名”登录失败”。

sqlcmd -S ${servername} -d ${dbname}  -U ${sqlusername}  -P ${sqlpassword} 
       -I -i ${inputfile} -s"|" -r1 1>${logfile} 2>${errorfile}

I tried to execute the same by providing values with password in single quotes.我试图通过在单引号中提供带有密码的值来执行相同的操作。 It worked fine它工作得很好

As we cannot hard code the password.因为我们不能硬编码密码。 I tried the things shown here, but those didn't work.我尝试了这里显示的东西,但没有用。

sqlcmd -S ${servername} -d ${dbname} -U ${sqlusername} -P '${sqlpassword}'
sqlcmd -S ${servername} -d ${dbname} -U ${sqlusername} -P "${sqlpassword}"
sqlcmd -S ${servername} -d ${dbname} -U ${sqlusername} -P \'${sqlpassword}\'

Can someone please help me - am I doing something wrong?有人可以帮助我 - 我做错了什么吗?

Thank for @Larnu's comment.感谢@Larnu 的评论。

The error caused by your password has has dollar sign in it.由您的密码引起的错误带有美元符号。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM