Cloud SlashDB VM can't connect with Azure SQL DB - azure-sql-database

I set up a SlashDB instance in Azure following the instructions here.
I set up an Azure DB which I can access just fine from SSMS using the server admin account. The DB server firewall seems to be properly connected to the SlashDB server vnet subnet's service endpoint.
When I let SlashDB compose the connection string based on host & DB names, I get this error:
Couldn't load model bromach_dev due to OperationalError. (pyodbc.OperationalError) ('08001', u'[08001] [unixODBC][FreeTDS][SQL Server]Unable to connect to data source (0) (SQLDriverConnect)') (Background on this error at: http://sqlalche.me/e/e3q8)
Connection Error (Default Connection String)
When I override the connection string with the ODBC connection string from the Azure Portal, I get this error instead:
Couldn't load model bromach_dev due to InterfaceError. (pyodbc.InterfaceError) ('IM002', u'[IM002] [unixODBC][Driver Manager]Data source name not found, and no default driver specified (0) (SQLDriverConnect)') (Background on this error at: http://sqlalche.me/e/rvf5)
Connection Error (Azure Connection String)
In this case, the connection string I am using is:
Driver={ODBC Driver 13 for SQL Server};Server=tcp:org-dev.database.windows.net,1433;Database=bromach_dev;Uid=serveradmin#org-dev;Pwd=****************;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;
Ideas?

In order for SlashDB to connect there must be an open TCP/IP route from its virtual machine instance to the Azure SQL Server (sorry if I am stating the obvious).
Also, there must be a working DNS resolver on SlashDB instance so it can obtain the IP address for your database host as configured in the connection string.
DNS Fix -- NO LONGER REQUIRED --
Let's begin with the latter. The new SlashDB image had a bug, which is caused by a bug in the Azure's publishing process https://github.com/Azure/WALinuxAgent/issues/1151. We have already published a corrected image to the marketplace. The following workaround is no longer requried:
Log in to your SlashDB instance via SSH using credentials you set at when you launched the instance.
Issue the following command
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
Firewall settings (easy) -- START HERE --
Using Azure portal, navigate to your database resource and click on the "Set server firewall" button.
Check if "Allow access to Azure services" is switched on. In our testing, a SlashDB instance running in the same location as the database server (East US in our case) with this setting turned on connected without problems.
Firewall settings (safer)
Using the same Firewall settings panel as above, turn off the "Allow access to Azure services". Instead we will add a network route for your SlashDB instance to connect. It's preferable to do so using virtual network rules as follows.
Click on the "Add existing virtual network" button in the bottom portion of the screen. A side panel will open.
Fill in the required details, most important the name of the virtual network of your SlashDB instance (you can find that in its "Overview" page in Azure Portal). Click OK.
Hit "Save".
Database Connection in SlashDB
Open your SlashDB user interface in the browser, navigate to Configure/Databases and click the "edit" button next to your database connection.
There is no need do override the connection string. Your database connection configuration should look something like this:
Once that's done click Save, then Close. You should now be able to successfully connect.

If your Azure SQL DB is not a Managed Instance, the SlashDB VM could not connect to it.
And please ensure the Azure SQL Database server firewall is properly connected to the SlashDB server vnet subnet's service endpoint.
The instructions about SlashDB also provides two solutions about how to solve the failed connection:
In addition, I think you maybe you can read this link for a reference:Configure Azure VM to connect to an Azure SQL Database Managed Instance
I hope this can helps you.

Related

Not able to connect to local SQL Server 2008

I have just recently downloaded and installed SQL Server 2008 on my laptop. I want to login using my local details.
I tried like this in my image below
but I get this error:
Kindly let me know how to connect it as I am new for doing first time installation.
There are many reasons..few listed below
Instance name may be incorrect..So try searching for all the available instances ..when you are connecting from local ,you can check that easily by try clicking on server name drop down and browse for more and clicking database engines
Once instance name is correct, you can try checking if SQL Server services are running by opening configuration manager
If SQL Server is running , you may want to check if network protocols are enabled in same configuration manager
One more reason could be SQL Server browser service not running..this helps you to connect to right instance when you have multiple instances running on same box and you don't specify port number while connecting
Do the following to troubleshoot:
Go into sql server connection manager and check if sql server services is running. If it is not running then start it.
If it is running, right click it and open it.
Copy name of instance from and paste that name in management studio connection window.
If you still get error try connecting it with ‘.’ In server name in ssms connection window.
If its still not working, go in sql server connection manager and check protocols. Check if named pipe protocol is enabled. If not enabled, enable named pipe protocol.
If you follow above steps you should fix the error you are getting.

Connect to Sql Server 2014 database into Azure VM

I just created a new SQL Server 2014 VM from Windows Azure gallery. I did remote login into VM , on trying to login into DB with Windows Authentication mode, I get below error:
Login failed for user 'dbserver\dba1'. (.Net SqlClient Data Provider)
Are there any specific steps, which I have to follow for new SQL Server DB login to work properly?
P.S. I have opened port 1433 into windows firewall, it did not help, althoug that should not be required for logging in directly from VM.
I guess Azure VM is not joined to domain. This means that only SQL authentication will work against this SQL Server instance. You might need to do the following:
Enable Mixed authentication on the SQL Server
Add a user mapped to SA role (or enable SA and set its password, but having separate user is better)
Open port 1433 (you did this already)
Make sure SQL is listening on this port (should be already)
In case you connecting outside of the same Azure Cloud Service - make sure you have endpoint created for the VM. Highly recommended to use port different from 1433 as the endpoint public port.
Don't forget to specify port if it is not standard, SQL connection string expects comma for it (i.e. myvmpublicname.cloudapp.net,12345)
You can check this article for more details
I was getting connection inside the VM using MSSQL Server, but not from outside. After reading some comments, I found that I needed to add a specific port for outgoing traffic and added that port at Azure firewall:
Here are the steps to check is it working for you or not:
Start Sql Server configuration Manager
Click on your Server name
Click SQL Server network config
Click on protocols
Click on TCP/IP
At the end of tcp/IP range set your port, I set 1433.
Please restart SQL Database.
Now open port at Azure management portal. And conntect through SQL tools or other services.
And also remember to open windows firewall.
It most likely installed another windows user as the admin for the SQL Database. If you know what that user is, login as them.
Otherwise, did you manage to set up the SQL in mixed mode and have an sa password. If so, login with that then add the Windows Account.
If not, try Forgot SQL Server Password to reset the sa password and get access that way.

How to connect to sql server database via LAN

want to connect to a database on another PC connected via LAN. I am able to use the sql server db with string like C:\Users... but i cannot connect using string like (\\Server\c\user...) I tried to move the db file to My Documents, still i get this error.
I get the following error message: An attempt to attach an auto-names database for file (\\SERVER\Users\Jeswills\Documents\TBSDB.mdf) failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share
I hope i asked the question correctly
As database does not support the '\SERVER\c...' parameters, i had to attach the database, after enabling TCP/IP and SQL Browser, i had to create a login through security and add it to the attached database file because authentication must be SQL not windows. And i also gave read/write privileges to the account. Then on the child system, i confirmed connection to the account through SSMS with the login connecting to SERVER (which is the remote computer's name).
Note: you must be able to ping the remote systems and SQL Server Express R2 installed. I tried with SQL Server Express but did not get a head way. www.connectionstrings.com/sql-server-2008 for more connection string
Then i used this connection string to connect remotely, making integrated security and user instance = false unlike if i were connecting locally.
Data Source=SERVER\SQLEXPRESS,1433;Database=DATABASEFILE.MDF;Integrated Security=False;Network Library=dbmssocn;Connect Timeout=30;User Instance=False;user='USERNAME';password='PASSWORD'
Not sure what specifically you’re trying to do here but I guess it’s one of these two.
Option 1
Attach database stored on remote shared drive to a local SQL Server
Note that this is only possible starting in SQL Server 2008 R2. If you’re running SQL Server 2008 this is not an option.
Check this for more details
http://blogs.msdn.com/b/varund/archive/2010/09/02/create-a-sql-server-database-on-a-network-shared-drive.aspx
Option 2
Connect to remote SQL Server instance from local computer
If that database is already attached to SQL Server instance that runs on the same machine then it’s much better to just connect to that instance from SSMS than trying to attach database from remote storage.
To do this you need to enable TCP/IP protocol in SQL Server Configuration Manager. It’s under SQL Server Network configuration node. Make sure you enable TCP/IP and also set enable the IP address for listening (this is under TCP/IP properties).
Apart from this you’ll want to enable remote connections on your remote instance. This is done from SSMS -> instance properties -> Connection tab
When this is done you should be able to connect to remote instance from local SSMS by typing in IPaddress/instance name. For example 192.168.0.125/{instance_name} or only IP address if this is default instance.

Named pipes provider could not open connection to SQL Server 1231

I am trying to set up a linked server and running into an issue.
On the target server I have configured a user, let's say Q. I have set the source server to connect with Q's login credentials no matter what user is logged in at Source Server.
However when I try to connect, I get the error
"Named pipes provider : could not open a connection to SQL Server
[1231]."
I have tried enabling and disabling named pipes in the server configuration manager, to no avail.
Also I have seen some things saying it is a security problem. The thing is, I am able to connect from Target to Source using Q's credentials in SQL management studio just fine.
Is there something stupid I'm missing here?
is the firewall at the linked server on?
check if the firewall is blocking the named pipes port, which usually is 445
try telnet to the linked server via port 445
Open Server Objects\Linked Servers, then Properties on your linked server. What did you enter here - maybe you are mapping some existing credentials to target credentials?
You should only check the option "Be made using this security context" and then enter Q and it's login. Also, check the "Server Type" to match the destination (Sql server)
On a side note, if the error were due to not supporting of named pipes, I thing you would get a different error, like "error 28 Server doesn't support requested protocol"..

Unable to Connect to SQL Server 2005 Db From Vista x64 Windows Service

I'm trying to connect to a remote SQL Server 2005 db from a .NET Windows service running in Vista Home Premium x64. I can access the remote db from a console app with no problem. I can connect to a local db from the Windows service with no problem. I was able to connect from a service from XP with no problem. There's no firewall or anti-virus running. How do I configure this service to be able to connect to the remote db?
I've tried to connect by running the Windows service as a local admin account, LocalSystem, LocalService, and NetworkService.
The connection string:
Data source=SERVER_NAME;Initial Catalog=DB_NAME;Integrated Security=True;
The error:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
MORE INFO:
I have also tried to connect using SQL Server authentication with no success:
Data Source=SERVER_NAME;User ID=USER_ID;Password=PWD;Initial Catalog=DB_NAME
This connection string works from the console app too.
MORE INFO:
I ran Process Monitor for the Windows Service and the console app. The Windows service showed \SERVER_NAME\pipe\sql\query was ACCESS DENIED but the console app showed SUCCESS when reading/writing files to \SERVER_NAME\pipe\sql\query.
Good Lord! Why all the gibberish and complex responses on this site. Create a User Account
Either local or Domain and set the service to use that account. Then go into your SQL Server and Add you new account to the Database and set permissions. Voila!
Oh yeah, dont plague yourself with SQL Authentication. Integrated Security is much easier to maintain and without a password in your web.config your much safer.
1) open a command prompt. Type "ping SERVER_NAME". Does it respond? You may have a DNS or connectivity issue if this doesn't work.
2) "telnet SERVER_NAME 1443". Do you see anything or does it refuse your connection? This will definitively tell you whether or not someone is listening on the other end.
3) Go into SQL Server Management Studio. Right click Properties of your server. Select "Connections" from the left side. Is "Allow Remote Connections" checked?
4) Since you're running using network service/system, you will need to make sure you have a login configured on your server for the machine account DOMAIN\CLIENTSYSTEMNAME$. Note the $ sign. This is your machine account, and this will be the user that SQL Server will see.