Connect SQLCMD in Linux using root user

Gnana Balaji Kanagaraj 41 Reputation points
2022-12-25T11:52:10.307+00:00

Hi, how to connect SQLCMD in Linux using root user?
We have SA account which got automatically disabled and there is no other login available to enable the SA Account or login to SQL Server SSMS.

So, is there any way to login to SQL Server using system account like root on linux sql server?

Please need help. TIA.

SQL Server on Azure Virtual Machines
Azure SQL Database
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,963 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,652 questions
0 comments No comments
{count} votes

Accepted answer
  1. Dan Guzman 9,236 Reputation points
    2022-12-25T12:42:20.937+00:00

    You can reset sa password and enable the account on Linux with mssql-conf set-sa-password. This requires stopping SQL Server, changing the password, and restarting afterwards. Example commands below.

    sudo systemctl stop mssql-server  
    sudo /opt/mssql/bin/mssql-conf set-sa-password  
    sudo systemctl start mssql-server  
    
    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Seeya Xi-MSFT 16,471 Reputation points
    2022-12-26T02:52:04.42+00:00

    Hi @Gnana Balaji Kanagaraj ,

    You can follow Dan's step to change sa password.
    Change the SA Password
    1. Stop the mssql-server service:
    sudo systemctl stop mssql-server
    2. Change the SA password:
    sudo /opt/mssql/bin/mssql-conf set-sa-password
    3. Start the mssql-server service:
    sudo systemctl start mssql-server

    About another question, it is not possible to connect to SQLCMD with the root user in Linux. There are only two types of authentication for SQL Server: Windows authentication and SQL authentication.

    Best regards,
    Seeya


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. Gnana Balaji Kanagaraj 41 Reputation points
    2022-12-26T09:26:27.503+00:00

    Dears, Thanks for your response, i have changed SA Password using Dan Steps and as soon as i changed the password i could able to login to the SSMS and able to connect.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.