HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

sqlcmd new login/user

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
loginnewsqlcmduser

Problem

I am new to sqlcmd and I want to create a new user. I have done the following:

1> CREATE LOGIN FYI_DBA WITH PASSWORD = 'V_2017'
2> go
1> CREATE USER FYI_DBA FOR LOGIN FYI_DBA
2> go


Then from cmd prompt I ran the following:

sqlcmd -s LOCALHOST -U 'FYI_DBA' -P 'V_2017'
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user ''FYI_DBA''..


What am I doing wrong?

Solution

Check that your SQL Server allows SQL authentication. By default it will be windows authentication only. You can check the SQL Server errorlog which will provide the login failure reason.

The message I you would see in the log in that situation would be


Login failed for user 'FYI_DBA'. Reason: An attempt to login using SQL
authentication failed. Server is configured for Windows authentication
only. [CLIENT: ]

You can change the authentication type using the GUI or T-SQL

Context

StackExchange Database Administrators Q#170762, answer score: 7

Revisions (0)

No revisions yet.