Visual Studio cannot connect to SQL Server database - sql-server

Getting a message "login failed for user [my_user]"
Of note is that I am capable of connecting to the server with freetds from linux using the same server, username and password and TDS protocol 7.4. The port is the default SQL Server port. Viz. $tsql -S [my_server] -U "my_user" -P "my_pass" succeeds and I am able to poke around in the server.
However, on my windows machine, it simply reports that my login has failed.
Data Source: Microsoft SQL Server
Server Name: [my_server]
Use SQL Server Authentication: User name: [my_user] Password: [my_pass]
Any thoughts on what to try?
UPDATE:
I can connect via pymssql with
pymssql.connect(server=[my_server], user=[my_user], password=[my_pass])

Related

Cannot connect to remote MSSQL on Azure VM(classic)

I'm trying to connect to an SQLEXPRESS database on an Azure VM(classic). My local machine is a Mac with sql-cli installed.
I have created a user within SQL Management Studio that is set to SQL Server authentication. I can connect with the credentials using SQL Management Studio on the server.
I have opened TCP 1433 in Windows (Server 2012) Firewall. I have added an endpoint in Azure for port 1433.
TCP/IP is enabled within SQL Server Configuration Manager.
I'm connecting with:
mssql -s [IP address] -u [user] -p [password] -d [database]
And I get the following message:
Error: Failed to connect to [Ip address]:1433 in 15000ms
What else can I check?

Unable to connect to SQL Server database from another machine

I need to access a SQL Server database which is installed on one machine and I want to access it from another machine. I have tried below options and nothing work
I have enabled TCP\IP with IPALL as 1433 in SQL Server Configuration manager
SQL Server and SQL Server Browser services are running, restarted after modified the configuration
Added SQL Server and TCP port to Windows firewall (allowed apps) as domain and public
Used
sqlcmd -S servername,portname -U username -P password -d database
What am I missing? On my local machine, it is working

Cannot Connect to Amazon AWS SQL Server Express database from Ubuntu SQL Server Express

I created an Amazon RDS database in SQL Server, created a custom security group with inbound rule type SQL Server protocal TCP Port "XXXX" Source "My PC's IP Address/32", allowed port "XXXX" over my firewall via "sudo ufw allow from any to any port "XXXX" proto tcp", successfully installed SQL Server on ubuntu via this tutorial: https://computingforgeeks.com/how-to-install-ms-sql-on-ubuntu/, and set 'public-accessibility' to 'no' in my AWS Database.
However, when I try to log in to my AWS Database from the command line via:
sqlcmd -S databasename.code.us-east-#.rds.amazonaws.com,XXXX -U username -P password -d DatabaseName
I get the error:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : TCP Provider: Error code 0x102.
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
I spelled everything correctly. What am I doing wrong?
Can you please check your network ACL's of your VPC and also make sure you have ephemeral ports allowed on your VPC ACL's.
https://docs.aws.amazon.com/vpc/latest/userguide/vpc-network-acls.html#nacl-ephemeral-ports

Login failed when I trying to connect to a SQL Server using sqlcmd (from Ubuntu command line)?

I am finding some problem trying to connect to a SQL Server instance from an Ubuntu machine using sqlcmd. The SQL server instance run on another server that is an always on MS-SQL Server cluster.
So I installed sqlcmd as explained here: https://learn.microsoft.com/it-it/sql/linux/sql-server-linux-setup-tools?view=sql-server-ver15#ubuntu
The SQL server seems to be reachable because I can successfully connect to the 1433 port of its IP via Telnet.
Then I tried to connect to one of my database on this server, in this way:
./sqlcmd -S MY-IP-ADDRESS -d ESB_WSO2_USER_DB -U datacenter\\wso2DBAdmin
Where:
ESB_WSO2_USER_DB is the DB name
datacenter\wso2DBAdmin is the domain\username
It ask me the password, I insert the password (pretty sure that the credential should be ok) but I am obtaining this error message:
Sqlcmd: Error: Microsoft ODBC Driver 17 for SQL Server : Login failed
for user 'datacenter\wso2DBAdmin'..
Assuming that username and password are correct: what could be the problem? Is it something that could be related to my sqlcmd installation (maybe some missconfiguration), or the driver? or something related to my connection string? or something related to the SQL Server database?

Allow SQL Server Remote Connection

I need to connect to remote SQL Server by an ip address with a port.
But when I ping to the ip address then that reply as well. But when I try to establish the connection that failed.
I tried with Management Studio and with command prompt too.
My command was:
sqlcmd -S [IP],[port] -U [user] -P [password]
The error report as follows :
HResult 0x274C, Level 16, State 1
TCP Provider: A connection attempt failed because the connected party did not
properly respond after a period of time, or established connection failed because
connected host has failed to respond.
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : A network-related or
instance-specific error has occurred while establishing a connection to SQL Server.
Server is not found or not accessible. Check if instance name is correct and if
SQL Server is configured to allow remote connections. For more information see
SQL Server Books Online..
Sqlcmd: Error: Microsoft SQL Server Native Client 10.0 : Login timeout expired.
I would like to know that
is there any missing steps from my client side for which I am unable to establish the connection?
or this is the matter of server configuration (Allowing remote connection)
It looks like you are actually missing the database name you would like to connect to:
EX: sqlcmd -S [IP],[port]\[DBNAME] -U [user] -P [password]
In addition to configuring the Windows Firewall to allow incoming connections on TCP Port 1433, you will need to start the SQL Server Browser service. This service can be found on the Start Menu - Microsoft SQL Server 2008 R2 - Configuration Tools - SQL Server Configuration Manager. Once there, click SQL Server Services on the left, then SQL Server Browser on the right. This is disabled by default.
Right click SQL Server Browser and choose Properties
Click the Service Tab
For property Start Mode, choose Automatic
Click Apply
Click the Log On tab
Choose the appropriate account for log on (I used built in service account)
Click Apply
Click Start
Click OK
This solved my problem on Windows Server 2008 R2 with SQL Server 2008 R2 Express Edition.
Check the firewall settings on the server that is actively hosting the database. By default, Windows Server will block all remote connections to the Database Server.

Resources