SQL Server Error: 1326 (the manager cannot connect to the remote database) solution, error1326

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

SQL Server Error: 1326 (the manager cannot connect to the remote database) solution, error1326

SQL Server Error: 1326

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. For example, 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 Files \ Microsoft SQL Server \ 90 \ Shared \ sqlbrowser.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.

Add: sqlservr.exe indicates that the Service PID is 1760 and the port number is 1433. Check whether the port is occupied. You can use telnet localhost 1433 to check whether the port is occupied, you can also use netstat IP | find "1433 'to identify who is using it. Conclusion: 1. Check the user name and password; 2. Check whether remote connection is allowed; 3. Check whether the firewall has enabled 1433 protection. (If you do not know, close the firewall and try again)

Thank you for reading this article. I hope it will help you. Thank you for your support for this site!

Related Article

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.