SQL2008 attaching database error 5120 and display as read-only solution after attaching database

Source: Internet
Author: User

SQL2008 when mdf is attached to the database, error 5120 is returned.

This error occurred when I used SQL2008 to open the MDF database file a few days ago.

 

 

When you use sql2008 to attach a database (including the database files being used in the x86 system and directly copying the files attached to the x64 system) on Windows 7x64 system, the system prompts that the file cannot be opened, an exception occurred when executing a Transact-SQL statement or batch processing. 5120 error.

This error occurs because the system does not have operation permissions. You only need to set the security attribute of this file or folder.

Solution:

1. Open the directory where the database file is stored or the properties window of the database file, and choose "properties"> "security"> "edit.

2. In the select group or user name list, select Authenticated Users and select full control in the permission list (neither user nor Erevyone permissions can be selected ).

3. Select "OK" to close the dialog box.

If the problem persists, use the administrator privilege to re-run SQLServer2008 to attach the database.

Solution to read-only display after attaching a database to SQL Server

After SQL2008 is added to a database, the database is read-only and unavailable in gray mode. You cannot perform other operations.

Solution 1:

In this case, the sa account is generally used for logon. You only need to change to Windows Authentication and then attach the database.

Solution 2:

Log on to SQL Server using sa to attach a database. After the database is attached, the database is read-only. Then, click database --> "attribute" --> "option" --> "status ", I found that "database is read-only" is True, and changed to false. If you can modify it, congratulations! you have a good character! When I modified it, I reported another error: error 5120.

 

 

In this case, find your data files and log files, right-click "properties" --> "security", and add a "Network Service" account, then, grant the account full control permissions. Log on to the database with sa again, and attach the database. You will find that the database is back to normal use and the read-only attribute is not available.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.