jemz
jemz

Reputation: 5123

How to add username and password in SQL Server 2014 Express database

How can I put username and password to my database mydb so that I can use it to my connection? Just like in MySQL we specify username = 'root' password = 'root'.

I am using SQL Server 2014 Express.

Upvotes: 1

Views: 635

Answers (1)

Ruslan K.
Ruslan K.

Reputation: 1981

CREATE LOGIN server_user WITH PASSWORD = '123456789';
GO

USE MYDB;
GO
CREATE USER [server_user] FOR LOGIN [server_user]
GO
ALTER USER [server_user] WITH DEFAULT_SCHEMA=[dbo]
GO
ALTER ROLE [db_datareader] ADD MEMBER [server_user]
GO
ALTER ROLE [db_datawriter] ADD MEMBER [server_user]
GO
GRANT EXECUTE ON SCHEMA::[dbo] TO [server_user]
GO

Upvotes: 1

Related Questions