Can't connect to SQL Server Express database - sql-server

I'm new to SQL Server Express, I'm running on a vagrant on SQL Server 2012 Express.
I configured user and password and I'm able to connect to the server, but when I add the name of the database I want to connect to it prompts with invalid user/password combination.
I created the database:
CREATE DATABASE db_user1
GO
And I have created the user using:
CREATE LOGIN [user1] WITH PASSWORD='user1'
GO
CREATE USER [user1] FOR LOGIN [user1] WITH DEFAULT_SCHEMA=[dbo]
GO
With no errors.

I had to add the new user to the sysadmin group.

Related

Azure SQL is not letting me create a SQL User

I have a Database server created in Azure [not a managed instance] and a Server Admin user was created, many SQL users were added and they were able to login without any issues. Now all of a sudden, SQL users I newly create can't login. It's giving Login failed message with Error# 18456
Here are the SQL commands I am using to create the user [after logging in as Server Admin]:
CREATE LOGIN reportslogin WITH password='' - this in "master" database
CREATE USER reportsuser from LOGIN reportslogin - this is in MyDatabase
ALTER ROLE db_datareader ADD MEMBER reportsuser - this again is in MyDatabase
Now I disconnect the server and when I try reconnecting to the server using the reportsuser, I get this:
What am I doing wrong?
Actually, the error is caused by you database login name.
You should using the Login reportslogin to login the database, not the username reportsuser !
We must using the login name to access the Azure SQL database, not the username.
A login is a simple credential for accessing SQL Server. For example,
SQL Login is for Authentication and SQL Server User is for Authorization. Authentication can decide if we have permissions to access the server or not and Authorization decides what are different operations we can do in a database. Login are created at the SQL Server instance level and User is created at SQL Server database level.
Please reference:
Login and SQL User
Difference between a User and a Login in SQL Server
Suggestions:
create the login and user with the same name:
USE master
CREATE LOGIN reportslogin WITH password='Xunmi110'
USE user_database
CREATE USER reportsuser FOR LOGIN reportslogin
ALTER ROLE db_datareader ADD MEMBER reportsuser
One login for one user.
Hope this helps.

Server principal already exists but doesn't show in SSMS

I have created Logins in Azure SQL via SSMS on two other environments, but on the third Azure SQL Server, the same exact SQL command creates logins but they don't show in SSMS. I am using these Logins to then users for databases. As I have stated it has worked on every other Azure SQL Server.
However, when I create my Logins, they don't show up under Security > Logins and if I try to create user for the db, I get the following error:
'myuser' is not a valid login or you do not have permission.
Here is my SQL to create the Login:
CREATE LOGIN myuser WITH PASSWORD = 'p#ssword';
Here is my SQL I run on a selected database to add the above created user with execute rights:
CREATE USER [myuser] FROM LOGIN [myuser];
GRANT EXECUTE TO [myuser]
To be clear, the Login (first SQL) said that it is created, but it doesn't show in SSMS and doesn't allow me to create Users in the DBs

Connecting to MS SQL Database from Pentaho

I am trying to connect to sql server from Pentaho. I have created a user on the database and I am able to connect with that user from Pentaho. However, the user seems to require the sysadmin server role. Without that role, the user is unable to connect from Pentaho. The error message from Pentaho simply states that the login failed for user.
The user is able to login without the sysadmin role from the SSMS application.
Does a user seriously need to be a sysadmin to connect from Pentaho?
No, user should not be sysadmin in order to connect to sql server from Pentaho. Create login first then map that login to user. Use the below commands.
create login login_name with password ='acds'
create user user_name for login login_name with default_schema='schema_name'

How to set up SQL Server Principal on Azure SQL database

I am trying to set up a connection string for an MVC website that uses an Azure website, and I am having trouble getting it to connect.
I can connect via SSMS using the SA account. But I would like to create a SQL Server principal that has data-reader, and data-writer privileges.
I have set up a SQL Server principal on Azure according to this.
However, when I try to log in with it using SSMS, I get the following message:
Unable to connect to default database 'Master' Login Failed.
This is the script:
CREATE LOGIN Test WITH PASSWORD='...'
use AskProd
go
Create user Test from login Test
go
exec sp_addrolemember 'db_datareader', 'Test'
exec sp_addrolemember 'db_datawriter', 'Test'
With Azure SQL your default database is Master and you can't change it. That is why it worked from the connection string where you specify a database but not from SSMS.
You can specify the database you want to connect to in the SSMS Server connection screen if you click on options.
Or if you want this new user to be able to connect to Master create a user for it in Master along with the login.

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