1

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:

enter image description here

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.

enter image description here

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

jarlh
  • 42,561
  • 8
  • 45
  • 63
Ogglas
  • 62,132
  • 37
  • 328
  • 418

1 Answers1

2

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.

Oscar
  • 13,594
  • 8
  • 47
  • 75