I have Microsoft SOL Server 2008 R2 on my server. When I am trying to open SOL Server Management Studio as administrator and creating new database, I get this error message
create database permission denied in database 'master' error 262
Also when I am adding sysadmin in login property window section in my login. Then this message appeared:
add member failed for server role 'sysadmin'
Please let me know how to add admin permission on my login and easily to create database
you need to login with SQL server authenticaton for craeting DataBase.
If you are using Windows Authentication then you need to run SQL server as Run As Adminstrator to avoid this error.
Further details Here People Having similar error
Login to your workstation as an administrator and execute the following query
EXEC sp_addsrvrolemember 'Domain\User', 'sysadmin';
CheckHere
Sql Server will not consider if you are admin to your workstation ,but you have to explicitly
make user as a sysadmin.
Intresting
Related
TITLE: Microsoft SQL Server Management Studio
Create failed for Database 'myDB'. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=14.0.17119.0+((SSMS_Rel).170517-0412)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+Database&LinkId=20476
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
CREATE DATABASE permission denied in database 'master'. (Microsoft SQL Server, Error: 262)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=12.00.2269&EvtSrc=MSSQLServer&EvtID=262&LinkId=20476
BUTTONS:
OK
I don't have an admin account outside of 'sa'(ı dont know the password). This account deauthorize(ı can't authorize). What can I do?
PREREQUISITES:
Administrative privileges needed on Host Server.
Downtime of approximately 10 minutes needed because SQL Server would be started in ‘Single User’ mode.
PROCEDURE:
RDP to the server with the account which has ‘Admin’ rights on the Hosting Windows box. Using a service account is good idea. -> skip this if your server is a local machine
Open ‘SQL Server Configuration Manager’ :
Start>All Programs>Microsoft SQL Server 2008 (or 2005)>Configuration Tools>SQL Server Configuration
Manager
Start SQL Services in ‘Single User Mode:
Right Click on SQL Services and click ‘properties’
Go ‘Advanced’ tab then open ‘Start up Parameters’
Write ‘-m’ at the end, then click ‘OK’.
This would open a dialog box informing that SQL Services need to be restarted for this. Click ‘OK’.
Stop dependent services like SQL Agent. Restart SQL Services.
Connect to SQL instance using SQLCMD
Right Click on Command prompt, select ‘Run as Administrator’ (in Windows 2003 and lower, run as administrator is not available and not required)
Now connect to SQL instance using SQLCMD, write below command:
SQLCMD –E –S <instance name>
Now create a windows login (i.e. group account used by DB team), use below command:
CREATE LOGIN [Login_name] FROM WINDOWS WITH DEFAULT_DATABASE=[master]
GO
Now grant ‘sysadmin’ access to this newly created login, use below command:
EXEC master..sp_addsrvrolemember #loginame = 'login_name', #rolename = 'sysadmin'
GO
Restart SQL Services in multi user mode. For doing that, remove ‘-m’ from Startup parameters and restart SQL
Services.
I just logged in to SQL Server 2005 with SQL Server Authentication but was stuck at the error message saying "Login failed for user ‘sa’, (Microsoft SQL Server, Error: 18456)". What happened to this?
In SQL Server Management studio right click in Object Explorer and ensure in the server properties - under Security the option "SQL Server and Windows Authentication mode" is enabled
If you are accessing the SQL Box remotely ensure the TCP/IP setting is enabled in SQL Server configuration manager.
Three things to check if you can't log in to SQL Server using the sa account:
1.Check the password and provide a new one if necessary
sp_password NULL, 'mypassword', 'sa'
2.Enable the sa account
ALTER LOGIN sa ENABLE
3.Check that the sa account is not being affected by the domain security policy
ALTER LOGIN [sa] WITH PASSWORD='yourpassword',CHECK_POLICY=OFF
I unknowingly deleted SA user from the SQL Server 2012. Now i cannot be able to connect to the sever. It shows an error :
Cannot open user database. Login failed. Login failed for the user 'username'.(Microsoft SQL Server, Error: 4064)
Now i don't know what to do?
Help me please
Thanks
When ever get this error,we have to create a new user with server authentication to connect the data base
We can create login for data base under security tab-->create new login under it
If you have Windows administator permissions, you can restart SQL Server in single-user mode. Any administrator can then log in locally and fix things.
Give this a shot as a place to start:
Connect to SQL Server When System Administrators Are Locked Out (MSDN)
Recently just upgraded to SQL Server 2008 R2 Express. When I attempt to create a database after logging in using Windows Authentication with my id myuser I receive this error:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
CREATE DATABASE permission denied in database 'master'. RESTORE HEADERONLY is terminating abnormally Error 262
If I try to add the sysadmin role to myuser, this is the error I receive:
Add member failed for ServerRole 'sysadmin'. (Microsoft.SqlServer.Smo)
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
User does not have permission to perform this action Error 15247
If I try to add this role to my user with T-SQL, using this command,
EXEC sp_addsrvrolemember 'ziffenergy\myuser', 'sysadmin';
GO
Here is the error I receive:
Msg 15247, Level 16, State 1, Procedure sp_addsrvrolemember, Line 29
User does not have permission to perform this action.
Does anyone have any suggestions? It seems that I can't do anything with database on the local machine. Please note that I am the administrator on the Windows 7 workstation I am using, and if I try to create or modify databases and/or users on our network IT Test database server using SQL Server Management Studio, I can do that with no problem.
Coming late to the party, but I found this fantastic step-by-step guide on getting control of your SQLExpress instance if you don't have your sa password. I used this process to not only reset my sa password, but I also added my domain account to all the available server roles. I can now create databases, alter logins, do bulk operations, backups/restores, etc using my normal login.
To summarize, you use SQL Server Configuration Manager to put your instance into single-user mode. This elevates you to sysadmin when you connect, allowing you the ability to set everything up.
Edit: I've copied the steps below - kudos to the original author of the link above.
Log on to the computer as an Administrator (or Any user with administrator privileges)
Open "SQL Server Configuration Manager"
Click "SQL Server Services" on the left pane
Stop "SQL Server" and "SQL Server Agent" instance on the right pane if it is running
Run the SQL Express in single-user mode by right clicking on "SQL Server" instance -> Properties (on the right pane of SQL Server Configuration Manager).
Click Advanced Tab, and look for "Startup Parameters". Change the "Startup Parameters" so that the new value will be -m; (without the <>)
example:
from: -dc:\Program Files\Microsoft SQL.............(til end of string)
to: -m;-dc:\Program Files\Microsoft SQL.............(til end of string)
Start the SQL Server
Open your MS SQL Server Management Studio and log on to the SQL server with "Windows Authentication" as the authentication mode. Since we have the SQL Server running on single user mode, and you are logged on to the computer with Administrator privileges, you will have a "sysadmin" access to the database.
Expand the "Security" node on MS SQL Server Management Studio on the left pane
Expand the "Logins" node
Double-click the 'sa' login
Change the password by entering a complex password if "Enforce password policy" is ticked, otherwise, just enter any password.
Make sure that "sa" Account is "enabled" by clicking on Status on the left pane. Set the radio box under "Login" to "Enabled"
Click "OK"
Back on the main window of MS SQL Server Management Studio, verify if SQL Server Authentication is used by right clicking on the top most node in the left pane (usually ".\SQLEXPRESS (SQL Server )") and choosing properties.
Click "Security" in the left pane and ensure that "SQL Server and Windows Authentication mode" is the one selected under "Server authentication"
Click "OK"
Disconnect from MS SQL Server Management Studio
Open "Sql Server Configuration Manager" again and stop the SQL Server instance.
Right-click on SQL Server instance and click on "Advanced" tab. Again look for "Startup Parameters" and remove the "-m;" that you added earlier.
Click "OK" and start the SQL Server Instance again
You should now be able to log on as "sa" using the new password that you have set in step 12.
You may be an administrator on the workstation, but that means nothing to SQL Server. Your login has to be a member of the sysadmin role in order to perform the actions in question. By default, the local administrators group is no longer added to the sysadmin role in SQL 2008 R2. You'll need to login with something else (sa for example) in order to grant yourself the permissions.
In SSMS 2012, you'll have to use:
To enable single-user mode, in SQL instance properties, DO NOT go to "Advance" tag, there is already a "Startup Parameters" tag.
Add "-m;" into parameters;
Restart the service and logon this SQL instance by using windows authentication;
The rest steps are same as above. Change your windows user account permission in security or reset SA account password.
Last, remove "-m" parameter from "startup parameters";
I followed the steps in killthrush's answer and to my surprise it did not work. Logging in as sa I could see my Windows domain user and had made them a sysadmin, but when I tried logging in with Windows auth I couldn't see my login under logins, couldn't create databases, etc. Then it hit me. That login was probably tied to another domain account with the same name (with some sort of internal/hidden ID that wasn't right). I had left this organization a while back and then came back months later. Instead of re-activating my old account (which they might have deleted) they created a new account with the same domain\username and a new internal ID. Using sa I deleted my old login, re-added it with the same name and added sysadmin. I logged back in with Windows Auth and everything looks as it should. I can now see my logins (and others) and can do whatever I need to do as a sysadmin using my Windows auth login.
I have 2 accounts on my windows machine and I was experiencing this problem with one of them. I did not want to use the sa account, I wanted to use Windows login. It was not immediately obvious to me that I needed to simply sign into the other account that I used to install SQL Server, and add the permissions for the new account from there
(SSMS > Security > Logins > Add a login there)
Easy way to get the full domain name you need to add there open cmd echo each one.
echo %userdomain%\%username%
Add a login for that user and give it all the permissons for master db and other databases you want. When I say "all permissions" make sure NOT to check of any of the "deny" permissions since that will do the opposite.
I got the same problem till I found this.
I open a new query and run the following
RESTORE DATABASE <YourDatabase>
FROM DISK='<the path to your backup file>\<YourDatabase>.bak'
then right-click on Databases -> Restore Database -> select Device -> click ... -> ADD your dataset -> Click Ok
I have installed SQL Server 2008 R2 on Windows XP.
In installation process I selected 'SQL Server and Windows Authentication Mode'
When I click right button of the mouse in SQL Server Management Studio on Server -> Security tab 'SQL server and Windows Authentication Mode' is selected.
But when I click on my Database -> Properties - View connection properties Authentication Method is set on Windows Authentication.
To my database was added one user1 with password user1.
But I can't log in to my database from C# (Visual Studio 2008) because error occurs:
Login failed for user 'user1' The
user is not associated with a trusted
SQL Server connection
What isn't right ?
When I get:
string connectionStr = #"Data Source=rmzcmp\SQLExpress;Initial Catalog=ResourcesTmp;Integrated Security=True";
I have following error:
{"Cannot open database \"ResourcesTmp\" requested by the login. The login failed.\r\nLogin failed for user 'RMZCMP\rm'."}
rm is my original user name on which I log in to my computer.
When I get rm I have error:
{"Login failed for user 'rm'. The user is not associated with a trusted SQL Server connection."}
again.
Regards
You say a user was created in your database - did you also create a login to your server?
In SQL Server 2005 and up, security is a two-step process:
you first must define a login that enables a user to even log in to that SQL Server
based on that login, you can define user in your individual databases
Also: you're not showing us your connection string, so we can only guess what settings you're using. From the error message, I'm almost guessing you're using Integrated Security in your connection string - but from your other points in the question, it seems you've created a specific user (and possibly a login for that user) - so you don't want to use integrated (Windows) security...
Most likely, your connection string is invalid - or you're missing a login - or both. You need to give us a bit more information for us to be able to really help!
Can you change your Connection string based on :
Connection string.com
Make sure that your installation of SQL Server is successful.
Ex:
If you can create a SQL Server authentication login
You can login using username/password in SQL Server authentication. Use a connection string like:
Data Source=Servername;Initial Catalog=DatabaseName;User ID=user;Password=sa
But
If you can login using only windows authentication there is something wrong in your installation. Use connection string:
Data Source=Servername;Initial Catalog=DatabaseName;Integrated Security=True
Regards!
That error suggests your application is set to log in with "trusted" (i.e. Windows) credentials and that the Windows account that the program is running as doesn't have a login on the server. Based on the way that you phrased the adding of a user, my guess is that it's a SQL login and you should change your connection string to reflect that.
I created user on my machine (where ms sql is installed)
User name is user1 and password too.
I can log on to Ms sql server on this user (user1)
My connection string is:
string connectionStr = #"Data Source = rmzcmp\SQLExpress; Initial Catalog = ResourcesTmp; User Id = user1; Password = user1;";
I user MS SQL Server 2008
rmzcmp is my computer name.
In ResourcesTmp (my database) ->Security ->Users I have: dbo, guest, INFORMATION_SCHEMA, sys, user1, user2
I don't have sa user.
User1 has following permissions:
Schemas owned by this user:
db_accessadmin
db_datareader
db_datawriter
Database role membership
db_accessadmin
db_datareader
db_datawriter
db_owner
Server properties -> Permissions ->Explicit tab:
Connect SQL : Grantor sa, Grant true.
User1 all checkboxes has false
Security tab -> Server authentication : SQL Serve and Windows Authentication mode is selected as I mentioned in earlier post
Regards
This problem occurs if the user tries to log in with credentials that cannot be validated. This problem can occur in the following scenarios:
Scenario 1: The login may be a SQL Server login but the server only accepts Windows Authentication.
Scenario 2: You are trying to connect by using SQL Server Authentication but the login used does not exist on SQL Server.
Scenario 3: The login may use Windows Authentication but the login is an unrecognized Windows principal. An unrecognized Windows principal means that Windows can't verify the login. This might be because the Windows login is from an untrusted domain.
To resolve this problem, follow the steps that apply to your scenario.
Scenario 1: Configure SQL Server in Mixed Authentication Mode.
SQL Server 2012, SQL Server 2008, and SQL Server 2005
Open SQL Server Management Studio. To do this, click Start, click All Programs, click Microsoft SQL Server 200x (where x is the version of SQL), and then click SQL Server Management Studio.
Right-click the server, and then click Properties. See image.
On the Security page, under Server authentication, click the SQL Server and Windows Authentication mode option button, and then click OK. See image.
In the SQL Server Management Studio dialog box, click OK to restart SQL Server.
see http://support.microsoft.com/kb/555332