sqlserver 閿欒18456

至于SQL Server连接字符串;非常复杂。
我记得我第一次看到这个东西的时候很困惑,但现在我明白了一些。
这就像一张地图,告诉 SQL Server 到哪里寻找数据。

首先,“IntegratedSecurity=SSPI;”下面我们就来说说这个认证方式。
集成安全性 集成安全性称为 SSPI,它是一种 Windows 身份验证方法。
简而言之,您使用 Windows 用户凭据连接到数据库,而不是用户名和密码。

然后“initialcatalog=”,这是指定要连接的数据库的名称。
例如,如果您有一个名为“test”的数据库,请在此处输入“test”。

“数据源=(本地);”请参阅这是指定的服务器地址。
这里写的是“(local)”,意思是本地服务器,就是你自己的电脑。

“connectTimeout=2 0”,这是设置连接超时时间。
换句话说,如果2 0秒内无法连接,就丢失了。
这2 0秒是分钟,不是秒。

最后一个是“”IntegratedSecurity=SSPI;initialcatalog=鏁版嵁搴揿敕;datasource=(local);connectTimeout=2 0"",这是完美的连接字符串。
这告诉 SQL Server 使用 Windows 凭据身份验证连接到本地服务器上的“鏁版偁搴揂悂”数据库。
如果 2 0 秒内无法连接,请不要等待。

说实话,当时我不明白每个参数是什么。
后来我慢慢研究,想出了怎么做。
不过现在用起来还是蛮方便的。

sqlserver数据库18456错误怎么解决(sqlserver错误18456原因)

说白了,以Windows身份验证方式进入数据库管理器更改密码、调整设置,其实很简单。
首先最重要的是,确保您的SA帐户密码复杂,例如包含大写字母、小写字母、数字和特殊字符。
The project we ran last year had a data volume of about 3 ,000, but it was broken by hackers because the SA password was too simple.
On another note, it would be a wise move to remove the need to enforce password policies. This way you can set a password that's easier to remember. 有一个细节非常关键。
For example, don’t set the password too short, at least 1 2 characters or more.
一开始我以为密码的复杂度越高越好,但后来发现太复杂的密码很容易忘记,管理起来更加困难。
Wait, one more thing, remember to check "Grant and enable". This is to ensure that your user permissions are set correctly.
Finally, confirm that the correct authentication mode is selected, here it is SQLSERVER and Windows Authentication mode. Many people don’t pay attention to this point, but it is actually very important.
Restarting the SQLSERVER service is very important because the changes will not take effect until the service is restarted. 说实话,这很令人沮丧。
Sometimes I forget this step, only to find that the permission settings have not been changed.
所以,我的建议是:在修改密码和设置权限时,一定要按照上面的步骤操作,并且修改后一定要重启服务。
您对这种方法有何看法?