简体   繁体   中英

LocalDb -> Windows Service -> Cannot open database “” requested by the login. The login failed. Login failed for user 'NT AUTHORITY\LOCAL SERVICE'

I have a problem connecting to LocalDb using the LOCAL SERVICE account.

Cannot open database "MyDB" requested by the login. The login failed. Login failed for user 'NT AUTHORITY\\LOCAL SERVICE'.

The service looks like this:

在此处输入图片说明

connectionString:

Server=(localdb)\mssqllocaldb;Database=MyDB;Trusted_Connection=True;MultipleActiveResultSets=true

I have created the user NT AUTHORITY\\LOCAL SERVICE in LocalDb and mapped the user as db_owner to the current databases. I have also checked that the login is enabled and has permission to connect to the database engine. I have also tried granting the user the sysadmin server role.

在此处输入图片说明

I have restarted both the service and the computer but I still get the same error.

If I change the service to use my local computer account everything works. What have I missed?

I have followed this guide but with LocalDb and NT AUTHORITY\\LOCAL SERVICE instead.

https://stackoverflow.com/a/3678481/3850405

Local Service account is not supported for the SQL Server or SQL Server Agent services. Instead, use a domain account or local account with the most restrictive permission set.

See this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM