Skip to content

mssql-conf set-sa-password doesn't work if the sa account has been renamed #939

@bluecreature

Description

@bluecreature

Hello,

Found a small issue with mssql-conf which I thought I'd let you know:

If the "sa" account has been renamed to something else via "ALTER LOGIN", then "mssql-conf set-sa-password" doesn't actually reset its password.

This is what I did in detail, in case I'm doing something wrong:

  1. Running in docker, docker run -it --rm --entrypoint /bin/bash mcr.microsoft.com/mssql/server:2025-latest . The same is reproducible with 2022, too.
  2. Run /opt/mssql/bin/sqlservr once to setup with MSSQL_SA_PASSWORD="<password 1>"
  3. Via /opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -P '<password-1>' -C :
ALTER LOGIN sa WITH name = superuser;
GO
exit
  1. Verify I can actually login as "superuser" : /opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U sa -P '<password-1>' -C
  2. Stop the server, then do MSSQL_SA_PASSWORD='<password-2>' /opt/mssql/bin/mssql-conf set-sa-password
<snip>
The system administrator password has been changed.
  1. Start the server again (/opt/mssql/bin/sqlservr 2>&1 1>testme.log &)
  2. Try to login with the new password
mssql@8a233b783aba:/var/opt/mssql$ /opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U superuser -P '<password-2>' -C
Sqlcmd: Error: Microsoft ODBC Driver 18 for SQL Server : Login failed for user 'superuser'..

mssql@8a233b783aba:/var/opt/mssql$ /opt/mssql-tools18/bin/sqlcmd -S 127.0.0.1 -U superuser -P '<password-1>' -C
1> ^D

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions