Mssqlserver failure remote database Error: 1326 Error solution

Source: Internet
Author: User
Tags change settings microsoft sql server mssqlserver management studio sql server management sql server management studio server port

When using SQL Server, we will encounter the problem that SQL Server Management Studio cannot connect to a remote database instance. The error description is excerpted as follows:
An error has occurred while establishing a connection to the server.
(Provider: Named Pipes Provider, error: 40-cocould not open a connection to SQL Server) (Microsoft SQL Server, Error: 5)
An error has occurred while establishing a connection to the server. when connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40-cocould not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)
After the above English translation, it is probably said that a connection cannot be established between databases because the named pipeline provider has an error. In fact, this is a typical database server setup problem, which may be encountered in the LAN or WAN. We only need to configure the database server to solve this problem, let's take a look at the specific steps.

Step 1: Make sure the database service on the server has been started
Start> All Programs> Microsoft SQL Server 2008> Configutation Tools. Open SQL Server Configuration Manager and click SQL Server Services to check whether the database service has been started. If the service is not enabled, start it manually. Of course, you can also choose Start> Control Panel> Administrative Tools> services in Windows to check whether the corresponding database service is enabled. Or if the Server and your machine are on the same network, you can run the "sqlcmd-L" command (note that L must be capitalized) to view all the available SQL Server servers in the network.

Step 2: enable TCP/IP in SQL Server Configuration
TCP/IP support is required for communication between multiple SQL Server servers over the network. To enable the SQL Server to be remotely connected, the TCP/IP must be enabled. Follow the steps described above to open SQL Server Configuration Manager, enable SQL Server Network Configuration, select the database you want to set, click TCP/IP, and right-click Enable. If necessary, you can also enable Named Pipes. Remember, all modifications take effect only after the SQL Server Service is restarted!
 

 
Step 3: enable the SQL Server port number in Windows Firewall
In many cases, we still cannot establish a remote connection after many settings on the database server itself. In this case, we need to consider whether the firewall is at fault. By default, many port numbers and services are disabled by the firewall and cannot be accessed or executed remotely. The default port number of SQL Server is no exception. We should reset Windows Firewall to add exceptions to SQL Server. Unless manually modified, the default port number of SQL Server is 1433. Add the port number to Windows Firewall. If SQL Server has a named instance, you should also add SQL Server browser to Windows Firewall. (The SQL Server naming example will be introduced later)
Open the Windows Control Panel and choose Windows Firewall> Change Settings> Exceptions> Add Port.
 
 
Click Add port... in the pop-up dialog box, fill in:
Name: SQL
Port Number: 1433
Protocol: Select TCP
 
Step 4: enable remote connection in SQL Server Manager
This step is usually ignored by the database administrator. If remote connection is not enabled, the database instance can only be connected locally but not remotely. Enabling remote connection is equally important. By default, remote connection is disabled. As shown in the following figure, open SQL Server Management Studio, right-click the database instance, and select the properties menu.
 
In the displayed window, select Connections on the left and select "Allow remote connections to this server ".
 
 
Step 5: enable the SQL Server Browser service
If SQL Server is not installed with the default instance name but a custom instance name, and the specified TCP/IP port number is not configured, as described above, SQL Server still does not support remote connection. However, if you enable the SQL Server Browser service, you can use the dynamic TCP/IP port number to remotely connect to the SQL Server. Enabling SQL Server Browser is very simple. Similar to enabling SQL Server, right-click SQL Server Browser in SQL Server Configuration Manager and choose enable. Enabling this service will affect all installed SQL Server instances on the Server.
 
 
Step 6: create an exception for the sqlbrowser.exe application in the fire wall
As we have mentioned earlier, to support remote connections to custom-named SQL Server instances, you must enable the sqlbrowser service. Windows Firewall may prevent the service from being executed. Therefore, you must add exceptions to the sqlbrowser service in Windows Firewall.
First, find the path to install the sqlbrowser.exe Program on the server, such as C: Program FilesMicrosoft SQL Server90Sharedsqlbrowser.exe. If you are not sure where SQL Server is installed, search for the file name in Windows. As described earlier, add an SQL TCP/IP port number to the firewall and add firewall exceptions to the sqlbrowser.exe application.
Finally, recreate the database alias.
It is common to create an SQL Server alias and use it in applications. The database alias can be used to ensure that once the database location changes, such as a new server or IP address, the database connection string in the application does not need to be modified. Otherwise, if you change the database location, you need to notify all applications using the database to modify the source code or the connection strings in the configuration file. This is probably impossible. Therefore, it is wise to use the database alias to configure the connection string. In addition, you can use the same alias to direct to different database instances. When modifying the alias parameter, you can immediately switch between databases. Creating a database alias is very simple. Select Aliases in SQL Server Configuration Manager to create a database alias.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.