Skip to content
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

Microsoft ODBC Driver 13 for SQL Server : Login failed for user 'SA' #94

Closed
edwardlau opened this issue May 17, 2017 · 14 comments
Closed

Comments

@edwardlau
Copy link

Hi:
Hi Run

docker run -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=Tt@12345' -p 1433:1433  --name mssql  -v  /data/mssql/log:/var/opt/mssql  microsoft/mssql-server-linux

and change the password 

docker exec -it mssql /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P 'Tt@12345' -Q 'ALTER LOGIN SA WITH PASSWORD="P@ss0wrd"

console show :

Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user 'SA'..

sa default password is ?
@twright-msft
Copy link
Collaborator

Is it possible that you created the container with the -v volume mount with a different password and then created a new container with the same -v volume mount with the password above? The first time you create a container the master DB files will be created in the -v volume mount directory and the SA password will be stored in the master DB. If you create a new container and point to the same -v volume mount then the existing master DB's SA password will be in effect and the SA_PASSWORD that you pass in will be ignored. See this issue for a description of this problem.

#89

Suggestion: If you dont care about the DBs previously created, stop all containers, remove all containers, delete the contents of /data/mssql/log on your host and start over.

@rcbapb
Copy link

rcbapb commented May 18, 2017

I have the same issue. I stopped and removed all containers and deleted all data. The problem remains. In the log file I see:
2017-05-18 11:42:46.48 Logon Login failed for user 'sa'. Reason: An error occurred while evaluating the password. [CLIENT: 172.17.0.2]

UPDATE: I found the issue, I am using Docker on Windows and I had to use double quotes (") instead of single quotes ('). After that, everything worked!

@twright-msft
Copy link
Collaborator

Closing out. Reopen please if needed.

@jasondaicoder
Copy link

I have the same issue when working with docker-compose. I have the compose file which defines the password using environment for sql server as below

environment:
 SA_PASSWORD: "strongpassword"
 ACCEPT_EULA: "Y"

However it always showing "Login failed for user 'sa'. Reason: An error occurred while evaluating the password. [CLIENT: 172.18.0.3]" error message.

I don't use any mounted volume and the container/images are all removed and re-created every time.

@dunfor
Copy link

dunfor commented Nov 12, 2017

The literal "strongpassword" does not conform to Microsofts password policies.

@jasondaicoder
Copy link

"strongpassword" is just placeholder. The actually password definitely complies with the policies.

@rezadj
Copy link

rezadj commented May 28, 2018

I get the same message in docker container on MacBook Pro sierra , I have used everything correctly.

@f22j
Copy link

f22j commented Jun 21, 2018

I'm getting the same error "Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'SA'. On MacBook Pro High Sierra.

@bilalmalik777
Copy link

bilalmalik777 commented Nov 27, 2018

If I run the container from the command line it is working perfectly but when I try to run from visual studio docker compose, it gets to run and getting the show in cmd. But giving the following error
"Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'SA'"

docker compose code is as follow

version: '3.4'

services:
webapplication1:
image: ${DOCKER_REGISTRY-}webapplication1
build:
context: .
dockerfile: WebApplication1/Dockerfile
depends_on:

  • "db"
    networks:
  • app-network

db:
image: microsoft/mssql-server-linux
environment:
sa_password: "Thingtrax#1"
MSSQL_PID: "Express"
ACCEPT_EULA: "Y"
ports:

  • "7002:1433"
    networks:
  • app-network

networks:
app-network:
driver: bridge

I am using windows 10 pro.Docker version 18.09.0, build 4d60db4
Already i have removed all the containers
Please help me to solve this issue

@EAbychkov
Copy link

Same issue here..

@bilalmalik777
Copy link

@EAbychkov are you facing same issue as i am.
So i have solved it

@EAbychkov
Copy link

Finally, I got the solution, I was needed to add:
-e 'MSSQL_PID=Enterprise'

And the overall command:
docker run -p 1433:1433 -v "c:\programdata\docker\volumes\sqldata:/var/opt/mssql" --name sql1 -e "SA_PASSWORD=1Q2w3e4r5t6y&U" -e 'MSSQL_PID=Enterprise' -e "ACCEPT_EULA=Y" -d microsoft/mssql-server-linux:latest

@jkockx
Copy link

jkockx commented Dec 22, 2022

If I run the container from the command line it is working perfectly but when I try to run from visual studio docker compose, it gets to run and getting the show in cmd. But giving the following error "Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user 'SA'"

docker compose code is as follow

version: '3.4'

services: webapplication1: image: ${DOCKER_REGISTRY-}webapplication1 build: context: . dockerfile: WebApplication1/Dockerfile depends_on:

  • "db"
    networks:
  • app-network

db: image: microsoft/mssql-server-linux environment: sa_password: "Thingtrax#1" MSSQL_PID: "Express" ACCEPT_EULA: "Y" ports:

  • "7002:1433"
    networks:
  • app-network

networks: app-network: driver: bridge

I am using windows 10 pro.Docker version 18.09.0, build 4d60db4 Already i have removed all the containers Please help me to solve this issue

Same issue here

Content of my Dockerfile

FROM willh/mssql-server-windows-developer:20H2
ENV ACCEPT_EULA=Y
ENV SA_PASSWORD=abcPwd123!
ENV MSSQL_PID=Enterprise
ENV MSSQL_TCP_PORT=1433
COPY CreateTestDB.sql ./CreateTestDB.sql 
RUN sqlcmd -S localhost -U sa -P abcPwd123! -i CreateTestDB.sql 

Runnning docker compose with my Dockerfile without the RUN command works fine and creates the image and runs the container. Afterwards I'm able to execture sqlcmd -S localhost -U "sa" -P abcPwd123! -i CreateTable.sql through the command line to alter the database.

However, when I add
RUN sqlcmd -S localhost -U sa -P abcPwd123!
to my Dockerfile, I get the following error:
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user 'sa'..

Anyone with a solutions for this?

@j-ew-s
Copy link

j-ew-s commented Feb 19, 2023

I have faced the same issue.
My docker-compose.yaml have two services one for MSSQL Server and other for MSSQLTOOLS

my.db:
      container_name: my.db
      image:  mcr.microsoft.com/azure-sql-edge
      environment:
        MSSQL_USER: SA
        SA_PASSWORD: "MyPass@word"
        ACCEPT_EULA: "1"
        MSSQL_PID: "Developer"
      ports:
        - "1433:1433"

  my.mssqltools:
      container_name: my.mssqlTools
      image: mcr.microsoft.com/mssql-tools
      depends_on:
        - my.db
      volumes:
        - ./SQLInitializationScripts/1-SetupStructure.sql:/tmp/1-SetupStructure.sql
        - ./SQLInitializationScripts/execute-scripts.sh:/tmp/execute-scripts.sh
      command: /bin/bash ./tmp/execute-scripts.sh

The execute-scripts.sh content

cd tmp
sleep 10
echo "DELAY TO GET THE DB READY" 
/opt/mssql-tools/bin/sqlcmd -S my.db -U sa -P MyPass@word -d master -i 1-SetupStructure.sql 

Notice that I had to do 2 steps to get it to work :

  1. Set a delay,
  2. set to sqlcmd -S the same service name i set on docker-compose.

Now its working fine!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests