Forum Discussion
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed for user
- Jul 21, 2024I have found this in the SQL Server rror log,
Login failed for user 'sw'. Reason: Password did not match that for the login provided. [CLIENT: <local machine>]
so I've opened a new topic for this.
John_S_Watson wrote:I cannot connect to a newly installed SQL Server with sqlcmd when using a password.
Is SQL Server running in "Mixed Mode" = Windows + SQL authentication?
By default SQL Server gets installed in "Windows only mode", SQL login don't work and raises errors like yours.
See Change server authentication mode - SQL Server | Microsoft Learn
- John_S_WatsonJul 21, 2024Copper Contributor
Thankyou for replying. In the Management Studio I have confirmed that the server's properties -> security -> server authentication is set to SQL Server and Windows Authentication mode, which I think is what is meant by "Mixed mode"?
I have also run the command it suggests,
EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE',
N'Software\Microsoft\MSSQLServer\MSSQLServer',
N'LoginMode', REG_DWORD, 2;
which I assume is mean to add a string variable to the key Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQLServer. It doesn't. I created the string variable LoginMode=2 through the registry editor, but still cannot login using a password.
Thank you, anyone, for any insight.- John_S_WatsonJul 21, 2024Copper ContributorI have found this in the SQL Server rror log,
Login failed for user 'sw'. Reason: Password did not match that for the login provided. [CLIENT: <local machine>]
so I've opened a new topic for this.- khosa460Sep 25, 2024Copper Contributor
t sounds like you're encountering a login issue with the SQL Server. Here are a few steps you can try to resolve the "Login failed for user" error:
Check Credentials: Ensure that you are using the correct username and password. Double-check for any typos.
User Permissions: Verify that the user has the necessary permissions to access the database. You may need to check with your database administrator.
Connection String: Make sure your connection string is correctly formatted. If you're using a SQL Server instance, include the instance name in the connection string.
Authentication Mode: Confirm that your SQL Server is set to the correct authentication mode (SQL Server Authentication or Windows Authentication). If you're using SQL Server Authentication, ensure that mixed-mode authentication is enabled.
Firewall Settings: Ensure that there are no firewall rules blocking the connection to the SQL Server.
ODBC Driver Version: Sometimes, issues arise from using an incompatible driver version. Ensure you have the latest version of the Microsoft ODBC Driver for SQL Server installed.