If you attempt to attach a database, and the mdf/ldf files are in a directory where your user account has privileges only through a group, you get an access denied error. If you grant the same privilege set directly to your user account, the attach succeeds.
Error: Operating system error 5: "5(Access is denied)". (Micorsoft SQL Server, Error: 5120)
Try following steps:
- Delete LDF file from folder where is saved your both files,
- Go to the [Management Studio] and try to attach the same database,
- When you come in window in which you select database to attach, you will see in second list its remarked that "LDF file is not founded",
- You just select LDF file and click on button [Remove],
- Click button [OK] and your database will be attached.
This happened because something of your privileges are saved in LDF file. For that reason you must to clear this information.
If it still doesn't solve then you can do the following steps:
- un-checking the [Read-only] attribute from the files and folders on this path,
- [Start] => [Run...] => type services.msc,
- Scroll through the list of services until you find 'SQL Server ...' => Right-click => [Properties] => Click on [Log On] tab,
- Copy the content of field [This Account] (e.g.: NT Service\MSSQL$SQLEXPRESS) => [Cancel],
- Right-click to MDF file => [Properties] => click on [Security] tab => [Edit] => [Add...],
- Fill with copied value from [This Account] in services => [OK],
- Checking the [Allow] for 'Full Control' => [Apply] => [OK].
Last steps if the ways above could not solve the problem:
- Right-click to [SQL Server Management Studio] then choose [Run as admnistrator]
- Try to attach the database. Once it is attached then you can access the database with normal way.
- Quit from [SQL Server Management Studio], then access [SQL Server
Management Studio] with usual authority (just click to the icon).
Source:
No comments:
Post a Comment