1

Background

I'm having to connect to a customer's Microsoft SQL Server. I generally don't need to do much in databases besides your average SQL, so using the database features in IntelliJ IDEA have so far been more than sufficient for various PostgreSQL and Orcacle databases. In this case though I was given a heads-up that I will have to change my password first, and when I use IDEA to connect with the credentials I received it does indeed reject them and gives me an error message saying I need to change my password. I was also told to use SQL Server Management Studio (SSMS) to do so.

Problem

SSMS is only for Windows, I'm running a Mac. The SSMS download page refers to Azure Data Studio for use on a different OS. An initial try of the latter did not let me change the password though. Even if I eventually find a way to do it, is there really no other easier way to do this that doesn't involve installing another full-blown db tool that I have no intention of using in the long run? Or worst case: buy a windows computer for the sole purpose of installing SSMS so I can change a password? Surely there must be a bunch of Mac- or Linux-using DBA's that know of a simple command-line tool or alike that allows them to change their password initially on a Microsoft SQL Server, after which they just use their favorite db management tool to access it?

Edit: Note on "duplicate"

I disagree that this is a duplicate of Handle expired SQL login's passwords in SQL Server because:

  • That question involves an expired password, while I was never able to log in in the first place, nor able to run any sort of SQL prior to logging in
  • That question involves someone already using SSMS, whereas I've specifically pointed out I cannot use it and I'm asking for an alternative

Additional clarification

  • When I said customer, I meant a client that has data that I need to pull. I do not have any sort of admin access to the VM or SQL Server beyond the credentials I was provided
  • The error I'm getting is not a notification while I'm logged in. It's an error preventing me from even connecting, so I cannot run any other SQL or commands whatsoever
3

Use SQLCMD for MacOS with the -z parameter for this.

| improve this answer | |
  • 1
    I used this with the -z parameter and it was exactly the alternative I was looking for. After changing the password I was able to use my preferred db querying tool and I didn't have to install SSMS, Azure Data Studio or buy Windows. Thank you for not disregarding my question as a duplicate! – Ricardo van den Broek Jun 2 at 16:19
3

mssql-cli is a command-line tool, available for Mac, Linux and Windows. See https://github.com/dbcli/mssql-cli/tree/master/doc/installation.

It isn't clear, however, if you can't login in the first place. If you can, then just change the password using ALTER LOGIN. If you can't, then you rely on the tool in question to (using any of the SQL Server APIs) to allow you to set a new password. SQLCMD (another command line tool, Win lony) for instance has command-line options for this. mssql-cli doesn't seem to have such options, at this point in time.

| improve this answer | |
  • I wasn't able to login in the first place, my apologies for not mentioning that specifically in my post. I've clarified it, thank you for mentioning it! – Ricardo van den Broek Jun 2 at 15:36
  • You could try mssql-cli and how it reacts. Perhaps it catches the return code that means (couldn't login, you need a new password), and allow you to do just that. mssql-cli being on Github, you could also check the source code for see how the login is handled, if you prefer that. – Tibor Karaszi Jun 3 at 8:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.