如何在SQL Server 2014 Express数据库中添加用户名和密码

时间:2016-04-15 07:19:55

标签: sql-server sql-server-2014-express

如何将用户名和密码放入我的数据库mydb,以便我可以将其用于我的连接?就像在MySQL中一样,我们指定username = 'root' password = 'root'

我正在使用SQL Server 2014 Express。

1 个答案:

答案 0 :(得分:1)

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