What should I do if I receive this - create database permission denied in database master?

1.9K    Asked by Aalapprabhakaran in SQL Server , Asked on Sep 29, 2022

 I am making a database in sql server and it shows an error that "CREATE DATABASE permission denied in database 'master'" I am using the administrator log in itself. What do I need to do? Please suggest a fix!

Answered by Al German

In case of - create database permission denied in database master - The user must be a member of the dbcreator server role for the user to have enough permissions to create a database. You can execute the following statement to make a user member of the dbcreator server role.

  EXEC master..sp_addsrvrolemember @loginame = N'Shubhankar', @rolename = N'dbcreator'

GO Or you Can/Should use

  ALTER SERVER ROLE  [dbcreator]  ADD MEMBER [Shubhankar];

GO

Members of sysadmin role are by default members of dbcreator server role therefore they can create databases too.



Your Answer

Answer (1)

If you receive the error "CREATE DATABASE permission denied in database 'master'", it means that your user account does not have the necessary permissions to create a new database. Here are the steps to resolve this issue:

1. Check Your Permissions

First, confirm that your user account does not have the required permissions:

USE master;

SELECT * FROM sys.database_permissions WHERE grantee_principal_id = DATABASE_PRINCIPAL_ID('YourUserName');

2. Contact the Database Administrator (DBA)

If you don't have the necessary permissions, you'll need to contact your DBA or the person responsible for managing database permissions. Request that they grant you the required permissions to create databases.

3. Granting Permissions

If you have access to an account with sufficient privileges (such as a sysadmin or a user with the dbcreator role), you can grant the necessary permissions to your user account.

Option 1: Grant the dbcreator Role

The dbcreator role allows a user to create, alter, drop, and restore databases.

  USE master;ALTER SERVER ROLE dbcreator ADD MEMBER [YourUserName];

Option 2: Grant Specific Permissions

Alternatively, you can grant specific permissions to create a database:

USE master;

  GRANT CREATE ANY DATABASE TO [YourUserName];

4. Verify Permissions

After granting the permissions, verify that the user has the correct permissions:

  USE master;SELECT * FROM sys.database_permissions WHERE grantee_principal_id = DATABASE_PRINCIPAL_ID('YourUserName');


3 Months

Interviews

Parent Categories