When I am creating a new 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?
create database Account
When I have executed the code this type of issue has occurred.
CREATE DATABASE permission denied in database 'master'. (Microsoft SQL Server, Error: 262)
Answer
Option 1.
- Go to SQL Server Management Studio and run it as Administrator.
- Choose Security > Then Logins
- Choose the usernames or whatever users that will access your database under the Logins and Double Click it.
- Give them Server Roles that will give them credentials to create a database. In my case, the public was already checked so I checked dbcreator and sysadmin.
- Run update-database again on Package Manager Console. The database should now be successfully created.
Option 2.
- Disconnect from your local account.
- Again Connect to Server with Login: sa and Password: PWD(PWD given to your local login).
- Object Explorer -> Security -> Logins -> Right click on your server name -> Properties -> Server Roles -> sysadmin -> OK
- Disconnect and connect to your local login and create a database.
Option 3.
To add a Windows user that has the login “machinename\Administrator” to the sysadmin fixed server role
- Log on to the computer using the credentials for the machinename\Administrator account.
- Click the Start button, point to All Programs, click Microsoft SQL Server, and then click SQL Server Management Studio.
- Connect to an instance of SQL Server.
- Click Security, right-click Logins, and then click New Login.
- In the Login name box, enter the user name.
- In the Select a page pane, click Server Roles, select the sysadmin check box, and then click OK.
Option 4.
Click on Start -> Click in Microsoft SQL Server Now right click on SQL Server Management Studio Click on Run as administrator
Comments