I'm trying to create a user in a SQL Server database with SQL authentication. That's what I did:
Created database named testDb (with default parameters)
ran script
CREATE LOGIN test
WITH PASSWORD = 'test';
USE testDb;
CREATE USER test FOR LOGIN test;
GO
Ensured user test appeared in Databases\testDb\Security (in Management Studio)
Tried to connect to the server with Management Studio using user test
Got 18456 error.
I'm using SQL Server 2008 Developer Edition. The OS is Windows 7 Ultimate. What am I doing wrong?
By default SQL Server logins are disabled.
You need to right click the instance in SSMS object Explorer then from the "Properties" dialogue, Security Tab enable "SQL Server and Windows Authentication mode".
This requires a restart of the SQL Server service to take effect,
Related
I want to convert my MySQL database to SQL Server, so that I can migrate my website into Azure.
I have two problems:
I downloaded SQL Server Migration Assistant for MySQL. I expect to see a "Connect to SQL Server" button, but there is only a "Connect to SQL Azure" button instead.
"OK" I said. "Why not convert it directly into Azure?" So I created an Azure account, and a SQL database in it. But when I tried to connect the MySQLToSQL to SQL Azure, it asks for user name, so I put my account email, "xyz#hotmail.com". It complained that "Cannot open server hotmail.com requested by the login". If I use "xyz", it complains "incorrect user name or password."
So what is my user name and password? I am totally new to Azure.
When you create a new project you specify the target database version in the Migrate To dropdown box. The default is SQL Azure. I suspect you didn't check the dropdown and created a project with the default value.
If you select another version, eg SQL Server 2016 or SQL Server 2014 you'll be able to use the Connect to SQL Server button.
Do you think it is possible to create a SQL server ODBC Connection for an active directory user who doesn't log in into the windows.
Ideally this type of users will be used in the batch process. So, Another person logs in and creates a batch process and runs it with another user.
Note: I dont want to create a SQL server authentication. Instead would like to use active directory.
Thanks.
You can't save alternate windows authentication credentials into an ODBC connection for SQL Server. You can only save credentials into the ODBC setting if you use SQL Server authentication.
There are other options though.
You can create a windows authentication ODBC connection to SQL server even if the account you create the connection with doesn't have database access. You just have to untick the "Connect to SQL Server to obtain default settings for the additional configuration options" and you can't use the "Test connection" feature. You just have to create the connection on faith.
With that connection, it will only work if your batch process or application is running as a different account to the logged-in user. Services that run as system accounts do this sort of thing. If you create an application that can be run as a service then you can change the account it runs under.
You can also run as another account manually. Using explorer you can [shift] + right-click on an application and choose "Run As different user" and then enter the other account credentials. Then when the process or application uses the ODBC connection, it will be the correct credentials and work.
There's also "ShellRunAs" https://technet.microsoft.com/en-us/sysinternals/shellrunas.aspx
I am using sql server 2008 R2 and in 1 scenario i need to change the default database from "master" to the "Test" as soon as i click on the New Query it will select default database to "Test". for this i am using following query to change the database priority,
Exec sp_defaultdb #loginame='sa',#defdb='Test'
i am able to change the default database to Test for sa Login but i wanted to change it in the Windows authentication mode i am connecting database using (local).
can any one know about what is the default user when we do login to the SSMS using Windows Authentication Mode. or any other solution to change the priority of database to Test?.
Thanks! in advanced.
In Windows authentication mode Your credentials to SQL Server are the same, like in Your System. For Example, in Non-Domain Environment, if Your Computer name is CPU, and login is USER, then Windows Authentication credentials would be : CPU\USER. If You try to connect from other PC, credentials would be different.
So, for answer for Your question : there is no default user when we do login to SSMS using Windows Authentication Mode.
For second question : You can do it for Windows Authentication User like in this example :
EXEC sp_defaultdb #loginame = 'CPU\USER' (Domain or Computer Name\Windows Login ) #defdb = 'Test'
I have a sql server 2008R2 express running in windows authentication mode. I created a login and a user for a database in sql server based on a windows account. I can connect to sql server database via(run as the user) SSMS and browse my database just fine.
Now i am trying to connect via a 3rd party asp application
set loginDB = Server.CreateObject("ADODB.Connection")
'For Windows Server 2008 / SQL 2008 users, please use the following line for the DB connection
loginDB.Open "Provider=SQLNCLI10; Server=(local)\SQLServerName; Database=dbname;Uid="myuser" Pwd="pwd""
I am getting an error saying login failed for user myuser
Also the site is running on an app pool which i have set it to run as the windows user myuser.
Where am i going wrong???
Thanks.
If you are passing username and password that's SQL Server Authentication not windows, so if it's authentication mode is Windows only, it won't have it.
Take them out and replace with Integrated Security = SSPI
Yesterday my database was connected perfectly.
We have installed Windows Server 2008 R2 on our server and the I have added the user to the client PC name SMTECH5 with user jangid
Now my database is not connecting using windows authentication.
only the master database is connecting.
Here's the the error:
Cannot connect to SMTECH5\COLLEGEERP.
Cannot open user default database. Login failed.
Login failed for user 'SMTECH\jangid'. (Microsoft SQL Server, Error: 4064)
If you go to enterprise manager as a different user, go to the security, logins node and select the user - then change the default database to master.
That should sort it.
The reason is because the default database has been removed (look comment on the question).
You have to Open Sql Server Management Studio, connect to the database, then open Security -> Logins-> right click on the account jangid -> Properties: on the bottom of the window you have to change the default database to the available one, or master.
Try this in SQL Server Management Studio.
1: Open 'Connect to Server' popup
2: Select 'Options >>'
3: Change the value in the dropdown 'Connect to database' from <default> to master.