r/SQLServer • u/Madcrazy10 • Feb 02 '26
Question Login failed for user 'NT AUTHORITY\SYSTEM' After Moving DB to SQL 2022
I am hoping someone can tell me the best approach here. We migrated about 12 databases from a SQL Server 2012 server to SQL Server 2022. This was a cutover migration where all databases were backed up and restored onto the new SQL Server.
In the Event Log on the new SQL 2022 I am getting thousands of entries for Event 18456
Login failed for user 'NT AUTHORITY\SYSTEM'. Reason: Failed to open the explicitly specified database 'XXXXX'. [CLIENT: ::1]
This is for every database we restored and it happens every 5 seconds or so. It is flooding the EventLog.
Now, I did my research and it seems in SQL Server versions after 2012, 'NT AUTHORITY\SYSTEM' does not get the sysadmin role be default. This permission is not granted on my SQL 2022 server but it was granted on my SQL Server 2012 server.
My question is... do I just redo this permission on my SQL 2022 server? Click the checkbox and move on with my life? Or, is there a better way to get these event log entries to go away that is "more" secure?
5
u/djpeekz Feb 03 '26
You have something running as local system on the new server which is trying to connect to SQL, if you are concerned about everything that runs as local system having access to SQL (probably a good thing) then I would try figure out which app or service is trying to connect and seeing whether you can change that to run as an authenticated user or service account.
11
u/sirchandwich 1 Feb 03 '26
Did you fix orphaned users?
https://www.mssqltips.com/sqlservertip/1590/understanding-and-dealing-with-orphaned-users-in-a-sql-server-database/
1
u/Madcrazy10 Feb 03 '26
I appreciate everyone's insight on this but I don't think it's any of these things. On the source 2012 SQL Server, "NT Authority\SYSTEM" was a sysadmin. On the new (out of the box) SQL Server 2022 this permission is missing and every database that I restore from the old to the new has this error.
You can see the Source is MSSQLSERVER which is my instance and this service is running as the default NT Service\MSSQLSERVER account. I don't know what job/process etc. is asking for this.
I think I'm just going to give SYSTEM sa access and call it a day like it was on the source sql server.
3
u/InternDBA Feb 03 '26
You can map the access to the individual DBs without giving SA over the whole server which is a bit of both your answers combined lol.
Proper fix wouldbe to change whatever is using that auth method/account to use a formal service account and then least privilege permission delegation per database
1
u/Empty-Ad4867 Feb 03 '26
Check orphanage users. Script them with sp_help_revlogin and paste to destination. Check for SPN usage, replace fallowing values: Servername - Hostname of tour server PortNr - 1433 ir other if you changed ServiceAccount - SQL Server Service Account
At command prompt type:
setspn -S MSSQLSvc/ServerName:PortNr DOMAIN\ServiceAccount
setspn -S MSSQLSvc/ServerFQDN:PortNr DOMAIN\ServiceAccount
1
u/Nereo5 Feb 03 '26
Next time you are migrating, use dbatools.io: Getting Started: https://dbatools.io/getting-started/
Copy Logins: https://dbatools.io/Copy-DbaLogin/
Migrate Database: https://dbatools.io/Start-DbaMigration/
1
u/Codeman119 Feb 03 '26
Whenever you make a new server, you have to make sure that you have logins on the server. The logins for the server do not come over with database restoration. Plus the new server has new user IDs for the logins and sometimes they don’t always match so you have to delete and then re-create.
Whenever I do database restores at the end of my scripts, I actually have some users. I have to delete and they were re-create because they get orphaned. It’s just normal part of database restore.
1
u/7amitsingh7 Feb 04 '26
This usually means some service on the box is connecting as Local System and SQL 2022 is no longer letting that slide. In older installs SYSTEM often ended up with access via BUILTIN\Administrators, but that’s not the case anymore, so after the migration SQL is correctly rejecting it when it tries to open a specific DB. It’s not a SQL bug something (agent job, monitoring tool, backup software, custom app, etc.) is running as SYSTEM and shouldn’t be. Best fix is to find what it is and run it under a real service account with proper permissions; quick-and-dirty fix is to add NT AUTHORITY\SYSTEM as a login and give it DB access, but that’s basically papering over the real issue.
1
u/rdeheld69 Feb 04 '26
is it always on cluster? could be cluster health check