The solution in this article applies to Microsoft Sql Server 2008/2012/2012 r2/2014 version, hereinafter referred to as MSSQLSERVER.
MSSQL does not allow remote connections by default, and disables the sa account. If you want to use SSMS to connect to MSSQLSERVER on a remote server locally, you need to configure two parts:
-
SQL SERVER MANAGEMENT STUDIO(SSMS)
-
SQL SERVER Configuration Manager (SQL SERVER CONFIGURATION MANAGER-SSCM)
And it should be noted that if some places do not take effect, please restart the sql server (you can find it from SSCM or from system services). Here are the detailed steps:
STEP1. Open SSMS, use the Windows identity to connect to the database, after logging in, right-click and select "Properties"
STEP 2. Select "Security", select SQL SERVER and Windows authentication mode
STEP 3. Then select "Connect", check "Allow remote connection to this server", and then click the "OK" button.
STEP 4. Expand "Security"-"Login Name-"sa, right click and select "Properties"
STEP 5. In "General", change your own password. This is the password for your sa login.
STEP 6. In the "Status", enable sa login and click the "OK" button
STEP 7. Right-click the database server and select "Aspect"
STEP 8. Select "Server Configuration", find RemoteAccessEnabled, and set it to "True"
STEP 9. Restart the SQL SERVER service and exit the current connection. At this time, you should be able to log in with sa.
STEP 10. Configure SSCM, select "SQL SERVER Service" on the left, make sure that "SQL SERVER" and "SQL SERVER BROWER" on the right are running, select "Network Configuration", double-click TCP/IP, and make sure the status is "Enabled"
STEP 11. Make sure that TCP/IP is enabled in the Client. The default port is 1433 and you can modify it yourself. Non-default ports need to be explicitly specified in the connection string.
STEP 12. Restart the SQL SERVER service here again, and it should be ready to use. But it still cannot be used. Confirm the firewall port settings and add C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Binn\sqlservr.exe to the allowed list under the SQL SERVER installation directory.