Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Today I couldn't start SQL Server process anymore. Reason:

The log scan number (213:18:1) passed to log scan in database 'master' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.

Ok, then I searched the internet looking for a solution for this strange problem and I found a blog post suggesting that I should replace master.mdf and mastlog.ldf files with the ones located in C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\Template Data and so I did.

Now I can start the process but I can't log in with neither my 2 previous login accounts. I thought that after replacing master I would at least be able to login with my Windows account, but I can't.

These are the login failed event logs:

Login failed for user 'andre-PC\andre'. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors. [CLIENT: ]

Login failed for user 'andrerpena'. Reason: Could not find a login matching the name provided. [CLIENT: ]

How can I work around this?

share|improve this question
One option for capturing logins for recreation is to periodically run the sp_help_revlogin script (such as in a SQL Agent job - except for SQLExpress) and save the output for when you need it. Or there are Powershell scripts out there to do something similar (such as – jl01 Feb 17 '12 at 14:10

Login details are stored in master, so it makes sense that they would be gone if you've replaced the master database files.

The files in the template data folder are referred to in User Instances for Non-Administrators as "clean system database". I don't have an Express edition to hand to check but I would assume that if your now using a "clean" master database, the only login that would be present is "sa" with a blank password.

share|improve this answer

You'll have to re-create your existing logins. Check this other question for details on how to recover / reset the sa password; once you have that, you can re-create your other logins and add your Windows account back to the local admin group (see this blog post for more details on that).

How do you reset the sa password?

share|improve this answer

The login information is stored in the master DB. Having replaced it will cause you to loose all the custom login information.

Do you have a copy of your old master.mdf and .ldf file, or did you overwrite them? If not, you will have to recreate all the logins.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.