本文讲SqlServer Express版本在登录的时候,
如何由Windows认证,修改为Sql Server Express认证。
目录
1,SqlServer Express的Windows认证
2,修改为混合认证
3,启用sa 用户
4,用sa 用户登录
下面是详细内容。
1,SqlServer Express的Windows认证
SqlExrepss版本安装完之后,默认的是Windows认证的。
就是下面这个样子的,Authentication选为 Windows Authentication选项。
然后你看到用户名都不是sa,也没法输入。
这个样子当然是可以登录的到数据库的,但是你装数据库也不是自娱自乐的吧,而是为了在VS.Net或其他环境当中进行连接的是吧,像这种,那你怎么连接呢?
那你说,Authentication下拉框改成 SQL Server Authentication不行吗?
出错了,错误信息如下:
TITLE: Connect to Server
------------------------------
Cannot connect to MYPC22\SQLEXPRESS.
------------------------------
ADDITIONAL INFORMATION:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - 证书链由不受信任的机构颁发。) (Microsoft SQL Server, Error: -2146893019)
For help, click: https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver--2146893019-database-engine-error
------------------------------
证书链由不受信任的机构颁发。
------------------------------
BUTTONS:
OK
------------------------------
这个怎么办呢?其实就是先进去,然后修改成混合认证就可以了。
2,修改为混合认证
改回Windows认证,然后点Connect,先进去
右键数据库节点,点Properties
点 Security
然后就可以在 Server authentication部分,修改为 SQL Server and Windows Authentication mode
提示说要重启示例,点OK
说实话,Express版本做得真实太简了
你直接给我重启得了呗,还得手动来😓
右键节点 > Restart
点 Yes
3,启用sa 用户
一般做示例之类的,大家也就懒得再去创建用户,直接就想用sa用户,这里来说明一下如何启用。
点 Security > Logins > sa,
右键 sa,点 Properties
设定Password
我这里就偷懒,不设置密码了,都为空
点 Status
Login:选 Enabled
回到登录画面
- Authentication:SQL Server Authentication
- Login: sa
- Password:空白
😓空白密码好像不太行哈。
TITLE: Microsoft SQL Server Management Studio
------------------------------
Enable Login. failed for Login 'sa'. (Microsoft.SqlServer.Smo)
For help, click: https://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=17.100.40.0&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Enable+Login.+Login&LinkId=20476
------------------------------
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
------------------------------
您不能启用空白密码登录。 (Microsoft SQL Server, Error: 15510)
For help, click: https://docs.microsoft.com/sql/relational-databases/errors-events/mssqlserver-15510-database-engine-error
------------------------------
BUTTONS:
OK
------------------------------
重新设置密码
csdn-shi_ly
点 OK按钮,
回到 sa,现在上面已经没有×了,也就是可以用了。
4,用sa 用户登录
回到登录画面
- Authentication:SQL Server Authentication
- Login: sa
- Password:自己设定的密码
又出 证书链由不受信任的机构颁发 错误。
这是为啥呢?
Connection Security:
- Encryption: Optional (可选)
加密由必须(Mandatory)改为Optional(可选),再点Connect
这回就OK了。
TODO:难道sa本来就可用?只是因为没有加证书而已。
欢迎朋友们研究一下并留言。
以上就是本篇的全部内容。
更多文章请点击东京老树根的博客主页
东京老树根-CSDN博客