SQL Server - error 5 access denied - sql-server

I try to attach a database and get an "error 5 access denied" error. I changed the permisions on the folder for the user "NT Service\MSSQL$MS64BITSQLSERVER" and gave full access but the error is still there.
The SQL Server service logs on as "NT Service\MSSQL$MS64BITSQLSERVER"
I'm sure that is an problem with the access rights. Any further suggestions?
Thanks and regards

The user which connects to database via windows authentication is already an Admin. But I must gave the user additional explicit full access on the folder which contains the files (properties/security). After that the error 5 file access disappears.

Related

Connection string "Login failed for user"

I'm trying to connect to my database using the following connection string:
Data Source=LORDKANELSNEGLE\SQLEXPRESS;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL13.SQLEXPRESS\MSSQL\DATA\Database.mdf";Integrated Security=True;MultipleActiveResultSets=True
However, this gives me the error Login failed for user "LORDKANELSNEGLE\Lord Kanelsnegle", despite me being able to login with those exact credentials in SSMS as shown here.
I've even tried adding the login from the Security tab within SSMS and received this error,
confirming that this login does in fact already exist (as if me logging in with them wasn't evidence enough).
I've read every other post, stackoverflow or other, that I could find regarding failed Windows Authentication logins for SQL Server but none of the solutions worked for me. Ideas?
You should remove AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL13.SQLEXPRESS\MSSQL\DATA\Database.mdf from your connection string.
You don't use localdb but fully functional Express Edition.
I imagine that your database is permanently attached to the instance and there is no need to re-attach it. So I think if you look in your SQL Server error log you'll see the error saying that it was impossible to attach that database because it's already attached and it was the reason of login failure.
Another reason can be that your login is not mapped to that database. In this case unless it's sysadmin it cannot enter the database. And this reason is also reported in error log. Server does not write the reason to the user in login failed error for security reasons but any sysadmin can find it in error log next to 18456 error

Error: Login failed. The login is from an untrusted domain and cannot be usedwith Windows authentication

I am working over LAN using sql server inside visual studio 2013. My server has an ip address of 192.168.0.19 and my client is 192.168.0.18 my port is 49170 which i configured at windows firewall. I connect the client into the ip address of the server but i always end up on getting the Error: Login failed. The login is from an untrusted domain and cannot be usedwith Windows authentication. I use windows authentication because i haven't set a username and a password through my installation. I think im getting the error because i must use the Sql Server Authentication. But how? I dont know what to enter on username and password. Please help. Thanks!
I had this problem today, and it was caused by my Active Directory account being locked out.
Yeah... perhaps the error message should've made that a little clearer !
To check if this is the cause for you, simply open a Command Prompt and run:
net user YourUsername /domain
For example: "net user jsmith /domain".
If your account is locked, it'll report this in the results.
I had the same issue recently. My account was not locked out, but my password had expired whilst I had an RDP session open (this session stayed open for days). Thus I could access the local SQL (on the RDP box) but when I tried to connect to a remote server in SSMS, I got the same error.
When I tried to RDP into the remote server, I then got a usable error message to the tune of... 'Your password has expired; change it or contact an admin'.
I change the password in my open RDP session; thereafter, I could login directly to the remote server, and could access it via SSMS in my open session.
Note: If I'd run the NET USER command as Mike suggests, I would have been able to see that the password expired the previous day:
To solve this you can disable the loopback check by adding a registry entry as follows:
Edit the registry using regedit. (Start –> Run > Regedit )
Navigate to: HKLM\System\CurrentControlSet\Control\LSA
Add a DWORD value called “DisableLoopbackCheck”
Set this value to 1
If above doesn’t solve the issue, we need to create SPNs for SQL Service account. While searching for SETSPN.exe command I came across this nice tool which can help a lot of pain like syntax error etc. is called as “Microsoft® Kerberos Configuration Manager for SQL Server®” which can be downloaded from https://www.microsoft.com/en-us/download/details.aspx?id=39046
The best piece about this tool is that it can help in finding missing SPN and provide script to run or fix it directly, if you have permission. Basically, it can
Gather information on OS and Microsoft SQL Server instances installed on a server.
Report on all SPN and delegation configurations on the server.
Identify potential problems in SPNs and delegations.
Fix potential SPN problems.
Taken from - https://blog.sqlauthority.com/2017/04/18/sql-server-login-failed-login-untrusted-domain-cannot-used-windows-authentication/

.wsf file creation always throwing File Access Denied Permission error

In Windows 7 I am trying to install SQL Server 2014 and the installation is failing every time while creating the file wscript.wsf with a permission error. I have full admin rights still not able to complete this installation.
When I try to create a blank file with the extension .wsf, Windows is throwing a "Permission denied" error also, and saying you need to get the Admin rights. I am using Administrator user.
Please help me to complete this installation
Regards,
Manohar

Attach sql server 2012 error, Unable to open the physical file

I got message box
Unable to open the physical file "C:\Project Basdat\DAYCARE.mdf".
Operating system error 5: "5(failed to retrieve text for this error.
Reason: 15105)". (Microsoft SQL Server, Error: 5120)
when trying to attach database file that I made from another pc.
I use Windows 10.
Help :(
The link I posted previously is broken so I removed it. If you run SQL Server Management Studio as administrator it should work just fine.
This is permission issue on folder.
GO to the folder where you have stored mdf file.
select file-> Right click -> click on .
give full permissions to file for logged in user Security and (NT Service\MSSQLSERVER).
When I faced this issue, I tried
Running SQL Management Studio as Administrator
Giving full permissions to the file for logged in user
Still the error persisted.
The reason for this error might be that you copied your program from a source which Windows considers non-trusted.
You can unblock the assembly by clicking "Unblock" after you right-click and select properties on the file.

Upload SQL Server database to server

I want to upload a SQL Server database to the server where my ASP.NET application is. The problem is that when I make a backup file and try to upload it to the server, I receive error that the access to the file is denied. I gave to the file all possible permissions but it still doesn't work. I try to upload the database to somee.com server. To do it I need to create an empty database and then upload mine. I tried to generate script but I get many errors while executing it on the server. Can you tell me how can I upload my database?
If the error is "Access Denied" then you, surprise, have been denied access. SQL Server does not have permissions to access the file. This error message is not known to be flaky or misleading.
Either you gave SQL Server the wrong path or the permissions you granted are not sufficient. Test, by granting Full Control to Everyone. Use procmon.exe to find the ACCESS DENIED error.

Resources