Remote connect to SQL Server Standard Edition from PHP/FreeBSD - sql-server

Unable to connect to our company MSSQL server from one of our FreeBSD servers.
# telnet 192.168.1.51 1433
Trying 192.168.1.51...
telnet: connect to address 192.168.1.51: Connection refused
telnet: Unable to connect to remote host
No firewall running on the MSSQL server, and i have opened the default port on the BSD-FW
00210 allow tcp from any to any dst-port 1433 in
00215 allow tcp from any to any dst-port 1433 out
Any ideas on this?
The specifics of the MSSQL server running on a Windows Server 2003

Test whether you can connect from another non-local machine. If not TCP connections may not be enabled for SQL Server. Here are instructions for enabling TCP/IP Connections with SQL Server 2000

I updated it MSSQL to Service Pack 4, and i'm now able to telnet to the server on the specified port. And also connect to the server from PHP with pdo_dblib

Related

Cannot connect DBeaver SQL Server to Rider, although DBeaver PhpMyAdmin MySQL connection works on Ubuntu

First of all, I work on UBUNTU, so please do not give me Windows solutions.
I want to connect my SQL Server (which is configured in DBeaver) to Rider (JetBrains).
Through DBeaver, I managed to establish a MySQL connection to PhpMyAdmin, via port 3306; this means that I can modify my PhpMyAdmin MySQL database x from SQL Server (DBeaver). However, when I intend to add a new Microsoft SQL SERVER connection in Rider (writing the correct username, password, database, server host and port) and test the connection, the classic error pops up:
[08S01] The TCP/IP connection to the host localhost, port 3306 has failed. Error: "The driver received an unexpected pre-login response. Verify the connection properties and check that an instance of SQL Server is running on the host and accepting TCP/IP connections at the port. This driver can be used only with SQL Server 2005 or later.". ClientConnectionId:69c13d8a-1f4f-4faf-ba64-b3a9b2ebcd13.
Note that if I connect to Rider via MySQL, everything works. The problem I face is SQL Server.
UPDATE:
It does not work on port 1433 either
UPDATE:
DBeaver MySQL connection

Connecting to SQLServer with GORM

I am using the statement below to try and open a connection to the latest download of SQLServer Express.
import (
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/mssql"
"log"
)
db, err := gorm.Open("mssql", "sqlserver://tony:Password6!#localhost:1433?database=go_user")
The statement results in an error:
2019/09/30 10:29:16 Unable to open tcp connection with host
'localhost:1433': dial tcp [::1]:1433: connectex: No connection could
be made because the target machine actively refused it. panic: Unable
to open tcp connection with host 'localhost:1433': dial tcp
[::1]:1433: connectex: No connection could be made because the target
machine actively refused it.
Is anyone successfully connecting to SQLServer Express with GORM on Golang?
TCP port 1433 is the default port for SQL Server. This port is also the official Internet Assigned Number Authority (IANA) socket number for SQL Server. Client systems use TCP 1433 to connect to the database engine; SQL Server Management Studio (SSMS) uses the port to manage SQL Server instances across the network. You can reconfigure SQL Server to listen on a different port, but 1433 is by far the most common implementation.
However, if you still want to open it, follow the below steps:
Step 1
Probably TCP/IP channel is disabled under SQL Server Configuration Manager. SO go there and enable all TCP/IP options.
Step 2
Just in case at the same place SQL Server Configuration Manager make sure you have 1433 port.
Step 3
Make sure that SQL server is configured to allow remote connections. Use MS SQL Management Studio and right click on the top node which server itself.
Credit from the solution found here.

Connecting to SQL Server 2017 with remote computer isn't working

I'm not able to connect to my SQL Server 2017 that is installed on my desktop from any remote computers.
Here are the steps and actions I have taken:
I followed all troubleshooting steps on https://learn.microsoft.com/en-us/sql/database-engine/configure-windows/troubleshoot-connecting-to-the-sql-server-database-engine#testing-a-local-connection
Turned off windows firewall on both computers (to eliminate this)
Tested tcp by connecting on the same computer as the server with tcp:localhost and I was able to connect
Used a port check tool to make sure the port was open
SQL Server remote connections allowed: http://prntscr.com/gvb1gb
SQL Server tcp/udp turned on: http://prntscr.com/gvb2yh
Router settings showing port forwarding is configured: http://prntscr.com/gvb3jm
I ran out of ideas and I don't know what else to do to connect to this sql server from a remote computer. Does anyone have any ideas on what I can try next?
UPDATE: I added port forwarding for 1434 udp in addition to the 1433: http://prntscr.com/gvbd01

SQL network-instance related issue (with error 258)

I get the following message when trying to connect to SQL database from a remote machine using MS Management Studio with Server Name [ XX.XXX.XXX.XXX,1433\MyServerName ] and SQL authentication:
Cannot connect to XX.XXX.XXX.XXX,1433\MyServerName.
ADDITIONAL INFORMATION:
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - The wait operation timed out.) (Microsoft SQL Server, Error: 258)
The wait operation timed out
I have done the following:
Allowed remote connection in Server Properties window in SQL Management Studio
Configured server machine to have static IPv4/DNS addresses.
Enabled TCP/IP in SQL Configuration Manager (in SQL Server Network Configuration)
In TCP/IP properties, adjusted [ Protocol -> Listen All -> No ] & set IP[1-8] to TCP port 1433 and IPAll port to 1433 (TCP dynamic ports left blank)
Set Inbound/Outbound enable connection (Domain, public, private) rules in Windows Firewall for ports TCP 1433, UDP 1434 (should make no difference, since port is specified), service executables: sqlbrowser.exe in C:\Program Files (x86)\Microsoft SQL Server\90\Shared (not used I think because port is specified) and sqlservr.exe in C:\Program Files\Microsoft SQL Server\MSSQL13.MyServerName \MSSQL\Binn
Set NAT actions in server-side router for ports 1433 (TCP), 1434 (UDP) (again, should not matter) to server's local IPv4 address and ports 1433, 1434 accordingly.
Made sure SQL service is running, ports are open and listening on server machine.
I can connect to the database on server machine using Windows or Sql credentials with either PC name, or machine's local IPv4.
Interesting thing is, when >telnet XX.XXX.XXX.XXX 1433 is run, it takes about 10-12 seconds to fail (Could not open connection to the host, on port 1433: Connect failed), but I can see the 2 packets coming to the router itself. Same with the login using SQL Manager - packets come to the router, but either server machine refuses (doesn't resolve?) the connection, or it doesn't even get to the machine.
Appreciate your suggestions.
Versions used:
MS SQL Server 2016 Express, MS SQL Management Studio 17, SQL Server 2016 Configuration Manager, Windows 10 Pro.
Have you tried telnet on 1433 locally?
Are you sure your local connection is using TCP/IP? By default, local connections use DBNMPNTW (named pipes) which uses shared memory on the back end for local connections and is faster than TCP/IP.
When SQL Server is working correctly on TCP/IP telnet will connect and leave you blinking waiting for protocol-- it doesn't hang for 10-12 seconds and fail.
If telnet works locally but not remotely, then you know the problem is in the networking layer (firewall, NAT, routing, etc.). If it does not, then the problem is in the SQL configuration setup. Did you restart the service after changing the connection settings?

How to connect to SQL Server in Win7 virtual machine from Mac host?

I restored a MSSQL backup to SQL Server Express in a Windows 7 virtual machine under Virtualbox. I am attempting to connect to this SQL Server instance from the host (Mac OS) using a user inside the imported database that has credentials to connect. The virtual machine is configured to use a Host-Only adapter. SQL Server express is running inside the VM at WIN7VM/SQLEXPRESS, port 1433.
I am able to connect to Apache in the VM on port 8080 from the Mac host without a problem. I can also telnet into the SQL server at port 1433 from the Mac host, using the host-only IP address (192.168.56.101).
What I am unable to do is connect to SQL server from Navicat in MacOS, or remotely using PHP. Here is what I have tried:
Disabled Windows Firewall
Configured SQL server port setting to use 1433
Enabled SQL server authentication
Enabled TCP/IP in SQL Server
Enabled remote connections to SQL server
I am trying to connect with this info:
Host/IP address: 192.168.56.101 OR 192.168.56.101\SQLEXPRESS (have tried both)
Port: 1433
Database: MyDatabase
Authentication type: Basic
Username: username
Password: password
What am I missing here to be able to remotely connect without any issues? Thanks in advance!
I believe you need to use a Bridged Adapter - rather than a Host-Only adapter. A Host-Only adapter does not use the physical NIC - so that is probably the issue here. I have encountered the same issue before.
Using a Bridged Network connection on both the Host and the Guest - will mean that both are on the same network. Assuming the firewall are not blocking port 1433, you should be able to connect without issue.
It turned out to not be a Virtualbox issue, but a SQL Server authentication issue.
The user I was trying to connect with had access to a database, but did not have a corresponding SQL Server Login.
MSDN - Managing Logins, Users, and Schemas How-to Topics

Resources