Cannot add user to SQL Server 2012 database - sql-server

I am trying to add a user to SQL Server 2012 Express by right clicking the users folder and clicking add.
I am selecting "SQL user with login" and filling out login info but it is giving me this error:
I am running Windows Web Server 2008 R2. I have tried different names in case it was conflicting and no joy. There is already a user in another database that someone else added previously. I tried to add a user to that database and got the same error so I am not sure what they did differently to me.
I tried running SQL Server Management Studio as administrator but when I do that the add user dialog changes and only lets me create windows user, no sql with login option is there.
I have also tried with a query:
CREATE LOGIN loginname
WITH PASSWORD = 'pass'
It says it is completed successfully but no user is created.
Anyone know what I am doing wrong?

You need to create a login to the server, then a user in the database.
Create Login
Create Database User
If you successfully created loginname, at the server level folder in SSMS, double click on the login and you will see options to grant the user permissions to the necessary database as well as assign a server level role. Once the login is configured and you have given permissions to the database, you can look in the User folder of the database and see the user.
Also answered in:
How do I create a new user in SQL Server 2012 that I can use in a connection string?

Does your SQL user you're logging in with have priv to create a user? This is not the same as launching the application with an elevation (right clicking the shortcut, and clicking run as administrator).

Related

Issue importing database to database project in Visual Studio

I have created a dev database in SQL Server and added a table in SSMS. I have created a .NET 6 application and created the database project and data project and now I am trying to import the database.
When I click select connection, it can find the database, if I select the Windows authentication option, it looks like it worked, but then the start button is greyed out.
If I select SQL Server authentication and try to use the login I have set up as db_owner in SSMS, I get this error:
Login failed 18456
I can login fine in SSMS as that login.
I am now stuck as to whether this is an issue with how I have set up the database and login user or whether this is an issue in Visual Studio. Please help!
I have checked that the login is set up as db_owner and systemadmin which it is.
I have also changed the default connection database for that user to the database rather than default or master.

Cannot create a new database in Sql Server - changed username

I installed Sql Server on a server in a company I used to work for.
I left the company - and rejoined a year later - and now I have a different domain login.
I've logged on to the server again, and in SSMS tried to create a new database - however I get the error:
create database permission denied in database 'master'
I have tried changing permission and adding DBCreator to BuiltInUsers and to SA - and also tried adding my new domain name to the security section - but when I try to add DBCreator to my user name, I get the error:
Cannot alter the server role 'dbcreator' because it does not exist or you do not have permission
Is there any way I can take control of the Sql Server instance again, to allow me to create new databases?
Thanks for any help,
Mark
I faced this problem when I made another SQL user which I login with, and I tried to give this user [dbcreator] grant.
I solved this via
runnig sql server as administrator
switching to my windows authentication.
going to folder Security -> Logins and double click on my new sql login user.
selecting Server roles and give grant to my user.

Can't log in with user of role db_owner

I'm running the following script and receive no errors nor warnings. I also verify that the user actually has been created. When I click on it, I get to see the roles (the membership db_owner is checked).
create login normalLogin
with password = 'normalpass',
check_policy = off
create login adminLogin
with password = 'adminpass',
check_policy = off
create user common for login normalLogin;
create user admin for login adminLogin;
execute sp_addrolemember db_owner, admin
However, when I try to log in to the server using admin as user name and adminpass as password (SQL authorization), I get the error message telling me this.
Login failed for user 'admin'. (Microsoft SQL Server, Error: 18456)
Accessing the helping link, I get two feasible suggestions.
Verify that SQL Server is configured in Mixed Authentication Mode.
Verify that SQL Server login exists and that you have spelled it properly.
I'm certain that (1) is correct (still, how can I re-check it?) so the suspicions fall on (2). Is the script above insufficient? I have the feeling that maybe the user on DB level isn't enough and that I need to create it on server level. Is it so? How can I script such an operation? I wish, of course, to keep the security tight and compartmentalized.
Can you try this:
Open your SQL Server Management Studio.
Database server right click and go to properties.
Choose Security option and check SQL Server and Windows authentication mode.
Enable TCP/IP connection in SQL Configuration Manager.
Restart your SQL server service.

Dotnetnuke Installation; Microsoft SQL Server 'sa' Account Problems

So I've been tasked to install DNN onto my system. I am using the Microsoft Web Platform Installer. I am being asked for the password for the 'sa' account. I do not know the password for the account. So when I tried to use the Microsoft SQL Server Management software to change the password I get the following message:
"Change password failed for Login 'sa' (Microsoft.SqlServer.Smo)
Additional Information:
An exception occurred while executing a Transact-SQL or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot alter the login 'sa', because it does not exist or you do not have permission. (Microsoft SQL Server, Error: 15151)"
How would I obtain permission to change the password? Or am I missing the point entirely and should be doing something else to install the software??
I would assume the issue lies with SQL, what steps should I take to rectify this problem??
SQL Server uses either/both of "Windows authentication" and "SQL Server authentication".
By default, MSSQL installs with ONLY "Windows authentication". "sa" requires MSSQL authentication.
SOLUTION:
http://technet.microsoft.com/en-us/library/ms188670.aspx
1) Go into SQL Server Management Studio Object Explorer, right-click the server, and then click Properties.
2) On the Security page, under Server authentication, select the new server authentication mode, and then click OK.
3) In the SQL Server Management Studio dialog box, click OK to acknowledge the requirement to restart SQL Server.
4) In Object Explorer, right-click your server, and then click Restart.
Are you able to login via Windows Authentication and change it that way? If so, that would be the best way to do it.
If the only account that has admin access is the sa account though, then you can try starting SQL server in single user mode and then resetting the sa password. Note that this method requires local admin access to the server itself.
http://sigkillit.com/2013/01/02/recover-sa-password-on-microsoft-sql-server/
Sounds to me like you could login with the SA account into SQL server, it will likely prompt you to change your password (first time logging in) and then you would be good to go after that.
That being said, I never recommend setting up DNN to connect to SQL server with the SA account. Each DNN database should have its own DB user, that way if one DNN install gets compromised for some reason, they can't reach out into other databases on the same server.
EDIT: a little more info
From http://www.christoc.com/Tutorials/All-Tutorials/aid/1
In SQL Server you should go through and create a new database. I always create a database with the same name as the website, so in this case DNNDEV.ME. Once you have created the database, create a user that can access that database. I always use SQL authentication, turn off the enforce password requirements, and give the user DB Owner and Public access to the DNNDEV.ME database. Remember the username and password you create here as you will need them when you walk through the Installation screen for DotNetNuke.

SQL Server 2008 can't login with newly created user

I'm using using Windows Vista and I'm having trouble logging in with a newly created user.
I open SQL Server Management Studio.
I create a new Login by right-clicking on Security->Logins.
Check: SQL Server Authentication
Login name: tester
Password: test
Click OK
I added this user to User Mapping to my database of choice.
Click File -> Connect Object Explorer, select SQL Server Authentication and enter tester/test and click Connect.
I get an error:
Login failed for user 'tester'. (Microsoft SQL Server, Error: 18456"
with Severity = 14 and State = 1.
What causes this error and how do I login with my user?
SQL Server was not configured to allow mixed authentication.
Here are steps to fix:
Right-click on SQL Server instance at root of Object Explorer, click on Properties
Select Security from the left pane.
Select the SQL Server and Windows Authentication mode radio button, and click OK.
Right-click on the SQL Server instance, select Restart (alternatively, open up Services and restart the SQL Server service).
This is also incredibly helpful for IBM Connections users, my wizards were not able to connect until I fxed this setting.
If you haven't restarted your SQL database Server after you make login changes, then make sure you do that. Start->Programs->Microsoft SQL Server -> Configuration tools -> SQL Server configuration manager -> Restart Server.
It looks like you only added the user to the server. You need to add them to the database too. Either open the database/Security/User/Add New User or open the server/Security/Logins/Properties/User Mapping.
You'll likely need to check the SQL Server error logs to determine the actual state (it's not reported to the client for security reasons.) See here for details.
Login to Server as Admin
Go To Security > Logins > New Login
Step 1:
Login Name : SomeName
Step 2:
Select SQL Server / Windows Authentication.
More Info on,
what is the differences between sql server authentication and windows authentication..?
Choose Default DB and Language of your choice
Click OK
Try to connect with the New User Credentials, It will prompt you to change the password. Change and login
OR
Try with query :
USE [master] -- Default DB
GO
CREATE LOGIN [Username] WITH PASSWORD=N'123456', DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english], CHECK_EXPIRATION=ON, CHECK_POLICY=ON
GO
--123456 is the Password And Username is Login User
ALTER LOGIN [Username] enable -- Enable or to Disable User
GO

Resources