Cannot connect to (LocalDB)\MSSQLLocalDB -> Login failed for user 'User-PC\User'
Solution 1
The following command through sqllocaldb utility works for me.
sqllocaldb stop mssqllocaldb
sqllocaldb delete mssqllocaldb
sqllocaldb start "MSSQLLocalDB"
After that I restarted the sql server management studio, and it is successfully established connection through (LocalDB)\MSSQLLocalDB
Solution 2
For this particular error, what gave me access to my MDF in VS2019 was:
- In Solution Explorer, right click your MDF file
- Detach
That was it and I now have access. I was expecting to detach and attach, but that wasn't needed.
I also could not get to my (localdb) in SSMS either, so what helped me there was a solution by Leniel Maccaferri. Here is the link to his site, along with the excerpt that helped me:
So guess what: the solution is ridiculously easy once you know what to do of course…
Click that Options >> button in Figure 1. Now select the Connection Properties tab.
SSMS Connect to Server | Connection Properties | Connect to database optionFigure 2 - SSMS Connect to Server | Connection Properties | Connect to database option
I had to type master in Connect to database field since I did not have it in the list of available databases.
Now click connect and you’re done.
Musakkhir Sayyed
Apparently, this user prefers to keep an air of mystery about them.
Updated on July 09, 2022