I think Olaf is correct your SQL Server is having currently Windows Authentication Mode you need to enable mixed more authentication. Post that a SQL Server service restart is required to make the change effective
Grant releveant access to a user in SQL Server
Hi Everyone,
I am new to this area and i request you to suggest me to come out of my confusions.
I have a data base in sql server 2017 as db_test and a user user1. I need to grant permissions to this user. I tried below scripts and executed the scripts with no errors. But when i am trying to log in with this user , i am not able to connect to the server itself. What i am missing here ?
CREATE LOGIN user1 WITH PASSWORD = 'Pa$$word123'
CREATE USER user1
EXEC sp_addrolemember 'db_datareader', 'user1'
GRANT CREATE SCHEMA TO user1
GRANT CREATE PROCEDURE TO user1
GRANT CREATE FUNCTION TO user1
Thanks in advance,
SQL Server Other
4 answers
Sort by: Most helpful
-
-
CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
2020-09-09T03:37:58.16+00:00 Hi @kirankumar-3620,
> Cannot open user default database. Login failed. Login failed for user 'user1'. (Microsoft SQL Server, Error: 4064)
According to the error message, please try to change the user's default database to a database that's currently available for a connection. Please refer to below blogs to get more information.
Error message when you connect to an instance of SQL Server: "Cannot open user default database"
SQL SERVER – Fix : Error: 4064 – Cannot open user default database. Login failed. Login failed for userIf It is not work, please let me know.
Best regards,
Cathy
If the response is helpful, please click "Accept Answer" and upvote it.
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. -
Olaf Helper 47,436 Reputation points
2020-09-09T06:31:23.427+00:00 Additional see Change server authentication mode
-
CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
2020-09-09T07:49:57.803+00:00 Hi @kirankumar-3620,
> The database xxx is not accessible. (ObjectExplorer)
You can also resolve this issue from SSMS UI as below screenshot. Right click user1 login > Properties > User Mapping
Best regards,
Cathy
If the response is helpful, please click "Accept Answer" and upvote it.
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.