问题
I created a login named logintest (SQL Authentication) then i created a user named usertest with this login
the user creation is successful, And i changed the authentication mode to mixed mode and also restarted the services SQLSERVERAGENT and MSSQLSERVER
and still this error appear when i try to login with the new user created
Cannot connect to SARAH.
Login failed for user 'usertest'. (Microsoft SQL Server, Error: 18456)
回答1:
The login must have CONNECT
right given.
The login must be enabled.
The default database linked to the login must be a database to which the login has rights to connect (for example by default master
database gives rights to guest
user to connect).
USE [master]
GO
ALTER LOGIN [logintest] WITH DEFAULT_DATABASE=[master]
GO
GRANT CONNECT SQL TO [logintest]
GO
ALTER LOGIN [logintest] ENABLE
GO
Then make sure the password is correct and that guest
user is enabled on master
database.
来源:https://stackoverflow.com/questions/43676698/cannot-login-to-sql-server-with-new-user-created