I have publish my website in IIS7. It is running in DefaultAppPool. The Identity of this app-pool is set to LocalSystem. The IIS is running and I can run the application from IIS without any problem.
Now I want to attach the database placed in inetpub's application folder:
C:\inetpub\wwwroot\EMSApplication\App_Data\ASPNETDB.mdf
I have added new logins in the SSMS which are: NT AUTHORITY\NETWORK SERVICE and IIS APPPOOL\DefaultAppPool.
But when I am trying to attach that database in the SSMS I am getting follwoing error:
TITLE: Microsoft SQL Server Management Studio
Failed to retrieve data for this request.
(Microsoft.SqlServer.Management.Sdk.Sfc)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&LinkId=20476
------------------------------ ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or
batch. (Microsoft.SqlServer.ConnectionInfo)
CREATE FILE encountered operating system error 5(Access is denied.)
while attempting to open or create the physical file
'C:\inetpub\wwwroot\EMSApplication\App_Data\ASPNETDB.MDF'. (Microsoft
SQL Server, Error: 5123)
For help, click:
http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=10.00.5500&EvtSrc=MSSQLServer&EvtID=5123&LinkId=20476
------------------------------ BUTTONS:
OK
By default Microsoft SQL Server Management Studio works against a Parent Instance of SQL Express, not your User Instance. A user instance is a separate instance of the SQL Server Express Database Engine that is generated by a parent instance. User instances allow users who are not administrators on their local computers to attach and connect to SQL Server Express databases. Each instance runs under the security context of the individual user, on a one-instance-per-user basis. Here is a manual from msdn How to connect to a User Instance.
I was able to do that running Management Studio As Administrator.
I had same problem.your .mdf and .ldf files don't have necessary permission.
you should add your windows account in both .mdf and .ldf files and give it full control permission.
Now you can attach your database successfully.
Related
I'm getting an error, says "Could not load the DLL xpstar.dll... Reason: 5(Access is denied)" right after logging into SQL Server Management Studio . Even though I can browse through the database schemas but I can't perform any action.
`My current configuration:
SQL Server Enterprise 2016
SQL Server 2016 Management Studio
Authentication mode: mixed mode`
SQL Server services
Binn folder permissions
What I've tried to figure out the cause:
Check Sql server services and they are all running.
Try connecting and performing some actions with SQLCMD (list tables, list db schemas...). It's all good.
Run SSMS as administrator.
Check permissions of BINN folder.
Disable Kaspersky Endpoint Security.
None of above steps can resolve the issue. So please kindly help me to fix it.
It turns out the folder ownership is the root cause. MSSQL and its subfolders were owned by SYSTEM. Even though Administrators group were assigned full control but They couldn't access to the folder. Probably, Kaspersky is involved. I'm not sure about that.
Solutions:
Change ownership of folder MSSQL (Drive:\Program Files\Microsoft SQL Server\MSSQLXX.MSSQLSERVER\MSSQL) from SYSTEM to Administrator.
Run SSMS as Administrator and problem is solved.
I am having an issue on viewing the SQL Error logs on SSMS. I'm aware that I'm also able to view the error logs by going to the folder where the error logs are stored. I have tried verifying if my service account has permission to access the error log location (read/write). Also my service account is granted sysadmin in SSMS. Still I'm unable to view the SQL Error Logs in SSMS.
In SQL Server Management Studio, select Object Explorer. ...
In Object Explorer, connect to an instance of SQL Server, and then expand that instance.
Find and expand the Management section (assuming you have permissions to see it).
Right-click SQL Server Logs, select View, and then choose SQL Server Log
https://learn.microsoft.com/en-us/sql/relational-databases/performance/view-the-sql-server-error-log-sql-server-management-studio?view=sql-server-ver15
TITLE: Microsoft SQL Server Management Studio
Create failed for Database 'myDB'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=14.0.17119.0+((SSMS_Rel).170517-0412)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
CREATE DATABASE permission denied in database 'master'. (Microsoft SQL Server, Error: 262)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=12.00.2269&EvtSrc=MSSQLServer&EvtID=262&LinkId=20476
BUTTONS:
OK
I don't have an admin account outside of 'sa'(ı dont know the password). This account deauthorize(ı can't authorize). What can I do?
PREREQUISITES:
Administrative privileges needed on Host Server.
Downtime of approximately 10 minutes needed because SQL Server would be started in ‘Single User’ mode.
PROCEDURE:
RDP to the server with the account which has ‘Admin’ rights on the Hosting Windows box. Using a service account is good idea. -> skip this if your server is a local machine
Open ‘SQL Server Configuration Manager’ :
Start>All Programs>Microsoft SQL Server 2008 (or 2005)>Configuration Tools>SQL Server Configuration
Manager
Start SQL Services in ‘Single User Mode:
Right Click on SQL Services and click ‘properties’
Go ‘Advanced’ tab then open ‘Start up Parameters’
Write ‘-m’ at the end, then click ‘OK’.
This would open a dialog box informing that SQL Services need to be restarted for this. Click ‘OK’.
Stop dependent services like SQL Agent. Restart SQL Services.
Connect to SQL instance using SQLCMD
Right Click on Command prompt, select ‘Run as Administrator’ (in Windows 2003 and lower, run as administrator is not available and not required)
Now connect to SQL instance using SQLCMD, write below command:
SQLCMD –E –S <instance name>
Now create a windows login (i.e. group account used by DB team), use below command:
CREATE LOGIN [Login_name] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
Now grant ‘sysadmin’ access to this newly created login, use below command:
EXEC master..sp_addsrvrolemember #loginame = 'login_name', #rolename = 'sysadmin'
GO
Restart SQL Services in multi user mode. For doing that, remove ‘-m’ from Startup parameters and restart SQL
Services.
this is a new staging server with SQL 2008. I'm not famliary with SSIS that much so trying to deploy a couple packages. So I do the following in BIDS..which is probably typical:
Right-click my solution, go to properties, then go to the deployment utility tab
Change CreateDeploymentUtility to true
Go and find the .SSISDeploymentManifest file locally on my machine
Run it and try to perform a SQL Server deployment to the customer's remote server (we're running vpn to get to it)
I put in the fully qualified remote server's name, my windows auth or SQL account (I tried both ways)
Try to click now the Package Path and get this:
TITLE: Package Installation Wizard
An OLE DB error 0x80040E09 (The EXECUTE permission was denied on the object 'sp_ssis_listpackages', database 'msdb', schema 'dbo'.) occurred while enumerating packages. A SQL statement was issued and failed.
ADDITIONAL INFORMATION:
An OLE DB error 0x80040E09 (The EXECUTE permission was denied on the object 'sp_ssis_listpackages', database 'msdb', schema 'dbo'.) occurred while enumerating packages. A SQL statement was issued and failed.
BUTTONS:
OK
So what do I do? How do I essentially run this as an administrator to get past this stupid elevated rights security error?
You should add your windows / sql account to sysadmin role.
In SQL Server Management Studio, go to Security -> Server Roles and double click sysadmin. Add your login and it should work when you try again.
SQLSEXPRESS service IS running!!
I have I program I wrote some time ago and it works. It was written in MS Visual Studio with local MDF file.
How is it possible to edit this file from Microsoft SQL Server Management Studio? I don't see this file in the list of globally connected databases.
If I try to attach this file with Visual Studio Wizard, I get message that such database already exists, but when I set arbitrary logical name, I get sharing violation.
How to reach MDF file?
EDIT 1
Now I found that my program also stopped to work.
The summary of results of different attempts to reach MDF file:
Program itself System.Data.SqlClient.SqlException (0x80131904): Cannot open user default database. Login failed. Login failed for user <username>. (windows user)
Visual Studio, Data source = Microsoft SQL Server, Logical Name = "" Error message: An attempt to attach an auto-named database for file
<filename> failed. A database with the same name exists, or
specified file cannot be opened, or it is located on UNC share.
Visual Studio, Data source = Microsoft SQL Server, Logical Name = SOMENAME Error message Unable to open the physical file <filename>. Operating system error 32: "32(The process cannot access the file because it is being used by another process )".
Cannot attach the file <filename> as database ‘SOMENAME’.
Visual Studio, Data source = Microsoft SQL Server Database File, Windows Authentication Error message: Cannot open user default database. Login failed. Login failed for user <username>.
Visual Studio, Data source = Microsoft SQL Server Database File, SQL Server Authentication Error message: Failed to generate a user instance of SQL Server. Only an integrated connection can generate a user instance. The connection will be closed.
Microsoft SQL Server Management Studio, Attach Database Error message: Unable to open the physical file <filename>. Operating system error 32: "32(The process cannot access the file because it is being used by another process)". (Microsoft SQL Server, Error: 5120)
MDF files are not intended to be used directly.
You may use them only through and with the help of SQL Server Engine.
Try this:
1- Create a database with the same name to mdf file.
2- Stop sql service
3- Go to the Data Carpet where is all mdf files and ldf , copy your original mdf file y replace.
4- Start the service
5- See in the management studio if the database still online there you go.
A .MDF database cannot be "opened".
It must be attached to an existing (and running) SQL Server instance.
If you have SQL Server Management Studio running, open a connection, and right click on databases. Choose "Attach" and point to the .MDF file. This will (attempt to) attach the database to the master database. If it works, the database will be visible in SSMS.