-
Notifications
You must be signed in to change notification settings - Fork 767
Why I can't login SA with docker #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Have you tried a different password? Try something relatively simplistic like Banana100 |
it doesn't work, I've changed more than 30 times the password.
|
I have the same problem. On my Windows 10 Pro (v 1803) I created my container from a powershell prompt:
Afterward, the following command works:
The above gives me access as "User Manager\ContainerAdministrator". However, the following command fails with "Login failed for user 'sa'":
I tried omitting the "-P SecurePassord" portion, so that it would interactively request the password. When I enter the password interactively, it still does not work. I have also tried a "docker rm" of the container, to start fresh. The second time around with "docker run" I put the password in quotes Incidentally, I have yet to find any MS documentation online that explains the "ContainerAdministrator" account and why it requires no password. Elsewhere I read that the 'sa' account is disabled by default for SQL Server. Perhaps that is the problem in this Docker context? I've not yet seen any documentation online, from any source, that explains how to enable the 'sa' account in a Docker container. Here is my "docker info": Containers: 1 |
I think I found the problem for both myself and @joelGarcia93 Password ComplexityIn my case, the password "SecurePassword" does not pass complexity validation. Instead of receiving an error, the container starts without any sign of an error. However, I can then no longer login as SA. I stopped and removed my container, then re-created it with "docker run" but this time I changed the password to "1Secure*Password1". Now having a complexity-valid password, finally I am able to log in as SA. Environment Variable NameIn Joel's case, I believe he is using an incorrectly named environment variable. Instead of:
I believe it should be:
ConclusionIf the the SA password is not specified, or if it does not pass a complexity test - the "docker run" command will not provide any indication that there is a problem. Perhaps this is where the real problem is? Cheers! |
at least for me, It doesn't work yet :(! I changed the Password as @brentarias said and also I changed SA_PASSWORD instead MSSQL_SA_PASSWORD.
some advice? thanks |
@joelGarcia93 - I tried your exact commands via copy/paste and got the same error on my macbook. I tried various combinations of things and ultimately got it to work by removing the MSSQL_PID env var. Ah hah! I thought I must have found a bug, but when I added it back to be sure, it still worked with the MSSQL_PID env var. Then I noticed what I think is the actual problem you are having. There is a sneaky little period after your password environment variable that is for some reason throwing everything off. Your original command:
Should be:
Output on my mac:
Please confirm and hopefully we can close this one out! :) |
@twright-msft Thank you so much, now it works like a charm!! Im gonna continue working with .Net Mvc Framework with Sql server. You are very kind, Thank you so much!! |
@twright-msft
Could you please help me in this? I don't know why the container exits immediately. |
Couple of things to try -
|
In my case I was running into the same thing but just with docker-compose. Turns out the the environment vars need to be quoted to handle special chars. Newbie mistake :)
|
I met this issue too. And I soled it.
To change a password and use SQL Server password policy.It works. |
Thanks for the suggestion. Worked in my case regarding password complexity part |
I found it. looks like it the " cannot be used to represent the password string. it should be used the ' ! |
Under Windows Under Mac no issue with single '. |
The problem is the password strangeness. I tried the @brentarias method and it worked! |
Try:
It is like the image is there and ready to run, you might only need to start the image. |
sudo docker run --name honeywell --hostname SQL --network="docker-network" --ip=172.18.0.8 -p 1434:1433 -e 'sa_password=Xkp7VmE6YHVDM' -e 'ACCEPT_EULA=Y' -d microsoft/mssql-server-linux:latest docker inspect -f "{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}" honeywell 8861458b9fe02f6fc35e445ec1813965e0a8b11fcae57ccd5b7a57167787fd9a sudo docker exec -it honeywell /opt/mssql-tools/bin/sqlcmd - S 172.18.0.8 -U sa -P Xkp7VmE6YHVDM |
Try with this: You don't have to specify the server (-S) when connecting to the local host SQL Server instance. However, you have do it when you are connecting remotely. Another option to avoid the password issue, is to set the SQLCMDPASSWORD environment variable within your container, something like this: SET SQLCMDPASSWORD=Xkp7VmE6YHVDM. So the next time you connect, you don't need to specify the password, something like this: sudo docker exec -it honeywell /opt/mssql-tools/bin/sqlcmd -U sa Good luck! |
@hal1987 Just checking, was your issue solved with the example above? If so, I think this issue can be closed :) |
It seems like if the SA password isn't set or is set to something invalid, this should fail the container creation. Is this not a bug, even though there is a workaround? |
change password to char/num only, work for me |
My issue was resolved after stopping the SQL Server instance (and its services) running on the host. |
I forgot to delete the <> sign while creating the password. So when I added this sign, I was able to log in. |
For me above resolutions did not work, @damian5996 solution works well for me! |
For someone who get this problem 2022, if I didn't add the following with MSSQL_PID I could not login.
|
I have the same error when tried to pass -P "anything" (with double quotes). |
Still doesn't work for me ;( |
This is my terminal, if i could get any help `still getting same error, after having tried multiple times.If anyone could identify whats wrong from my terminal below🥲 mac@Ghosts-MacBook-Pro ~ % docker images REPOSITORY TAG IMAGE ID CREATED SIZE mcr.microsoft.com/mssql/server 2019-latest 9ab26f8e5685 5 weeks ago 1.61GB mac@Ghosts-MacBook-Pro ~ % docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES mac@Ghosts-MacBook-Pro ~ % sudo npm install -g sql-cli Password: npm WARN config global --global, --localare deprecated. Use--location=global` instead. changed 48 packages, and audited 49 packages in 6s 1 package is looking for funding found 0 vulnerabilities |
I have " Login failed for user 'sa' "error for this comment:
it worked when i changed the comment like below:
|
If you are running into this issue, It could mostly probably due to password policy enforced by SQL Server. To check this you can run this command This would show you an error message like this You can run this command on Mac to get the containers running,
Later run these two commands to check If everything is working fine.
|
I faced the same issue here, SA_PASSWORD works but in this article https://learn.microsoft.com/en-us/sql/linux/sql-server-linux-docker-container-troubleshooting?view=sql-server-ver16&pivots=cs1-bash it says MSSQL_SA_PASSWORD. |
@rnmulchandani If you're using a regular Command Prompt in windows, that CMD command interpreter doesn't use single quote |
I've literally tried every last thing on this thread and I get the exact same error, cannot log into SA, and I've tried every complexity or lack thereof that you can imagine on passwords. WHY is this still broken half a decade after this issue was created?! Especially with a company like Microsoft owning this repo, there's less than zero excuse for that. Either support macOS or don't. The Docker container was the "solution" for Mac users at a developer conference I'm at and I've literally wasted the money I spent trying to get this working! If this doesn't work for macOS, used by plenty of developers even in 2023, then at least own that. (I even tried all of this with Microsoft's own Docker container, same results, so I don't think it's the fault of the workshop instructor, past not sufficiently testing before this session. He SHOULD have been able to trust this to work!) |
Having same issue but in my case it was even more complicated by the fact that i was using volumes,
|
I deleted the entire Container between attempts, specifically to avoid that issue. |
I was doing the same, but that was not enough. Following @seizezeday advice, I deleted the container, image AND all of the files that had been created locally when creating the volumes. I was then able to set up a new password, and that allowed me to log in. |
Hello im trying to install Sql server in Docker to can use it in my Mac. but since 2 days ago I can not fix this error, I've noticed is a popular issue but I don't know how to solve it. someone can help me? before of all Thank you!
MacBook-Air-de-Joel:~ joelgarcia$ docker run --name sql_server_demo -e 'ACCEPT_EULA=Y' -e 'MSSQL_SA_PASSWORD=Jko3va-D9821jhsvGD'. -e 'MSSQL_PID=Enterprise' -p 1433:1433 -d microsoft/mssql-server-linux:2017-latest d4848181f0a171f0b1b29cc59489961432894016c3ac9f0304d180a66c7343e6 MacBook-Air-de-Joel:~ joelgarcia$ mssql -s localhost -u sa -p Jko3va-D9821jhsvGD Connecting to localhost... Error: Login failed for user 'sa'.
I also tried with this
MacBook-Air-de-Joel:~ joelgarcia$ sudo docker exec -it sql_server_demo /opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P Jko3va-D9821jhsvGD Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'sa'..
The text was updated successfully, but these errors were encountered: