Connect to database over internet - sql-server

I'd like to connect to my MS SQL database hosted on another computer over internet.
What I did:
-> I'm using NO-IP (dynamic DNS)
-> I created SQL Authentication Account and I can connect to it from local computer using MSSMS like this:
Server name: local_ip\SQLEXPRESS Login: ###, Password: ###
-> I disabled firewall
-> I set port in SQL Server Configuration Manager (to 49XXX) and forwarded this port AND 1434 in router settings to my computer
-> SQL Server Browser is running
Now I'd like to connect to this DB from another computer (different network): Server name: tcp:my_no_ip_name.ddns.net,49XX Login: ###, Password: ###
I can't connect. All the time I get "Cannot connect to my_no_ip_name.ddns.net"
Am I missing something?

on local ssms, try to connect as yourserver.ddns.net,portnumber\instancename. windows authentication doesnt work on mine but ok with sql server authentication (try to avoid using sa account). dont forget to port forward on the router and open port in sql server firewall. Leave the ports on default (1433) in config manager. Not the most secure but once it works you can harden it by changing it to a non-default port and using a more secure user id in sql server logins which only has access to the database you want...

Related

How to connect to Azure SQL Database through a VM jump host using DBEaver?

What I have:
Azure SQL Database on private virtual network
Jump host - Whitelisted Azure VM that can connect to the Azure SQL Database
Local machine --PuTTY--> Jump Host --sqlcmd--> Azure SQL DB
What I want to do:
Usually I PuTTY into the VM and use sqlcmd to operate, but the GUI is difficult to view when query a lot of data. So I want to use DBEaver on my local machine to access the Azure SQL Database.
Config used:
In Connection setting -> Main: Azure SQL Database (same server host, port, database, username, and password as usually used in sqlcmd)
In Connection setting -> SSH: Jump host
In Connection setting -> Main -> Edit Driver Settings -> Libraries: jdbc 9.4.1.jre8 and jdbc_auth 9.4.1.x64
Problem I face:
I tried to use ssh tunnel configuration to connect. In image 1, when I click "Test tunnel configuration", it can successfully connect to the whitelisted VM.
a) In image 2 main config, I tried to use hostname in host and click "Test connection". It failed with error message
Cannot open server "127.0.0.1" requested by the login. The login failed.
b) In image 2 main config, I changed hostname as server IP (using ping <hostname> in jump host) and retry. It failed with error message
Cannot open server "127.0.0.1" requested by the login. The login failed.
c) In image 2 main config, I tried to use random IP address in host and click "Test connection". It failed with error message
The TCP/IP connection to the host 127.0.0.1, port 45851 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.".
What am I missing?
dbeaver ssh tunnel config
dbeaver main config
We have got the same issue.
Azure SQL Database needs to know the instance name associated to your username. Since you are using an ssh tunnel on 127.0.0.1, Azure can't know the name of the instance. You need to add the database name to your sql login (not the one used for the jumpbox, but the one used to connect to the db):
username#database_name.database.windows.net
Instead of
username

SQL Server 2008 login error

I try to login to SQL SERVER 2008 from another computer (IP is 10.225.3.137).
The database name is MSSQLSERVER2008, TCP protocol is port 49172.
The account is SQL Server Authentication.
I read from an article here to login to the database engine from another computer. Server name is "tcp:10.225.3.137,49172" and it works.
Here is the sceenshot:
I try to login from another computer to this database with server name is "10.225.3.137\MSSQLSERVER2008" but it doesn't work. Here is the screenshot. However, with the same server name on computer that installed SQL SERVER 2008, it works.
Anyone here can explain for me please? And how to login to that database from another computer with server name is "10.225.3.137\MSSQLSERVER2008"?
Be sure that SQL server is listening on default port and is set up for remote access and firewall is set up for default port 1433 and TCP/IP connections are enabled.
Looking at both images, it looks like it is not listening on port 1433 but 49172. Then change your connection to read:
10.225.3.137,49172\MSSQLSERVER2008
(you might prefix with tcp:)
Note: I have an old series of videos on youtube if you kike to watch, that shows setting up SQL server express locally and then connecting from remote using a custom port (search for "AccuSQL installation" on youtube and you would see 4 parts of videos - part 3 or 4 was about remote connection).
And BTW that is called an "INSTANCE" not database.

Unable to connect to remote SQL Server database from local management studio

I have purchased a VPS from GoDaddy. I installed SQL Server on the VPS through remote desktop connection and could connect to the database. Login credentials used are ServerName:IPAddress, Username=sa; Password=****
However when I tried to connect to the remote database from my local machine I am getting the error as
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.
I have cross checked the following scenarios
Made sure that TCP/IP is enabled
Made sure that SQL Server Browser is running
How can I solve this issue ?
You may have to add the IP address of your local machine to the server. Setting the IP to accessible. For security reason, it is not allowed to access the server for all the host except the host with the IP address that was added to the whitelist.
You can find the instruction in this web page.
From the web page:
If you want to connect remotely to a database, you must enable
support for remote connections.
Log in to your GoDaddy account.
Click Web Hosting.
Next to the cPanel account you want to use, click Manage.
In the Databases section, click Remote MySQL.
In the Host field, enter the IP address from where you want to access your databases.
Click Add Host.
What to enter... Host Name or Server: Your database's host
name Port: 3306 Username: The database user's username
Password: The database user's password Database: The name of the
database

How to find MS SQL Port without admin access?

Im setting up a Ubuntu server in my office which is going to be used for automatic reporting. Ive set it up with the LAMP stack. Ubuntu 16.04 server edition.
Im getting an error when Im trying to connect to one of my companies MsSQL servers through PHP on my new server:
Failed to get DB handle: SQLSTATE[HY000] Unable to connect: Adaptive Server is unavailable or does not exist (severity 9)
Ive set up my connection with the default port for MsSQL which is 1433. However its not working.
I have READ rights to this SQL Database.
Are there any ways to find out what PORT the SQL server is listening on? Without contacting the IT Dept. (they are on vacation)?
nmap is a great port scanner.
sudo at-get install nmap
nmap -p- 192.168.1.1
If your target is not 192.168.1.1 you should change the IP.
Read this.
Looks like it is because of misconfiguration of SQL Server. Following steps are required to gain remote access to SQL Server:
Enable TCP/IP access for SQL Server: Start -> All programs -> Microsoft SQL Server YourVersion -> Configuration Tools -> SQL Server YourVersion Configuration Manager -> SQL Native Client Configuration -> TCP/IP -> right click -> enable.
Add Inbound rule for Windows Firewall allowing access for 1433 port from required network (or hosts).
Enable authentication for both SQL Server and Windows modes. In SSMS, right click on connected instance -> Security -> Server authentication -> SQL Server and Windows authentication.
Make sure your login (Security -> Logins -> YourLogin) have all required rights.
With all this information, you have to contact your SQL Server DBA and ask him to check out configuration.

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