Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No SQL Server Express logins have permission to create db

I cant create a new db because there are only 2 logins:

sa
BuiltIn\Users

I get permission denied when trying to create the db even though I am the admin. How can I add a user with permissions at this point or must I reinstall?

like image 427
zsharp Avatar asked Nov 20 '09 06:11

zsharp


People also ask

How do I get permission to create a database in SQL Server?

If the user account not having the access in SQL Server, please follow the below steps to add the role. Step 2: Right click “Login” and select the user account under which you want to create the database. Step 3: Right click and select properties tab. Step 4: Under “Server Roles” tab, select “dbcreator” checkbox.

How do I enable SQL Server Authentication in SQL Express?

In SQL Server Management Studio Object Explorer, right-click the server, and then click Properties. On the Security page, under Server authentication, select the new server authentication mode, and then click OK.

Can we create user without Login in SQL Server?

After creating a user with “SQL User without Login” type, the user will have to login using their own credentials into SQL Server. It means that the user who is logged in will have his/her own username and password. Once the login is done in SQL Server, the user will be able to use the application.


1 Answers

I assume SQL Authentication is disabled and builtin\users is not sysadmin (ie. you locked yourself out).

Stop the Express service, start the server in admin mode (sqlservr -m -s SQLEXPRESS from command line), connect to the admin instance and add builtin\administrators back as sysadmin. Then stop the administrative instance (Ctrl-C) and start back the the normal instance.

Since Vista/Win7/Win2k8 remove the administrator token from your context under normal UAC, it makes sense to also add as sysadmin yourself explicitly (domain\user) so you don't have to use RunAsAdministrator to connect.

See How to add a Windows user to the sysadmin fixed server role in SQL Server 2005 as a failure recovery mechanism.

like image 175
Remus Rusanu Avatar answered Sep 24 '22 07:09

Remus Rusanu