Thursday , November 21 2024

The database dbname is not accessible

 

ERROR:

The database dbname is not accessible. (Object Explorer)

EXPLANATION:

Actually, I wouldn’t write an article for this error, but when I saw that it was the most searched article for another and a similar error, I wanted to write it.

You may receive this error when you try to open one of the databases under Databases in the Object Explorer window in SQL Server Management Studio. The probable cause is that you do not have access to the database you are trying to open.

SOLUTION:

You must request authorization for your SQL Login to access the relevant database. In most cases, only access is not sufficient. You will also need authorizations such as read (db_datareader) and write (db_datawriter).

Of course you need to determine the authority you need, I just made a very general description.

In the meantime, let me tell you what I mean by the access authorization. I’m talking about having a user in the relevant database. You can create it as follows:

The following user will be created by mapping to the specified Login and will now be able to access the database. However, you should consider that authorizations such as read and write will be given by separate commands. By default, the following user will only be created as a member of the Public role. In most databases, the Public role is not authorized. That’s the right thing.

 

Loading

About Ekrem Önsoy

The original article was written in Turkish by Ekrem Önsoy and translated to English by dbtut with the consent of the author. The copyright of the article belongs to the author. The author shall not be liable in any way for any defect caused by translation.

Leave a Reply

Your email address will not be published. Required fields are marked *