Skip to content

Commit c0fc8b2

Browse files
author
David Engel
authored
Add some DSN clarifications
1 parent 32f87bc commit c0fc8b2

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

docs/connect/odbc/linux-mac/connection-string-keywords-and-data-source-names-dsns.md

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: "Connecting using ODBC"
33
description: "Learn how to create a connection to a database from Linux or macOS using the Microsoft ODBC Driver for SQL Server."
44
ms.custom: ""
5-
ms.date: "01/19/2017"
5+
ms.date: "05/11/2020"
66
ms.prod: sql
77
ms.prod_service: connectivity
88
ms.reviewer: ""
@@ -16,7 +16,9 @@ ms.assetid: f95cdbce-e7c2-4e56-a9f7-8fa3a920a125
1616
author: David-Engel
1717
ms.author: v-daenge
1818
---
19+
1920
# Connecting to SQL Server
21+
2022
[!INCLUDE[Driver_ODBC_Download](../../../includes/driver_odbc_download.md)]
2123

2224
This topic discusses how you can create a connection to a [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] database.
@@ -30,34 +32,40 @@ See [DSN and Connection String Keywords and Attributes](../dsn-connection-string
3032
3133
The value passed to the **Driver** keyword can be one of the following:
3234

33-
- The name you used when you installed the driver.
35+
- The name you used when you installed the driver.
3436

35-
- The path to the driver library, which was specified in the template .ini file used to install the driver.
37+
- The path to the driver library, which was specified in the template .ini file used to install the driver.
3638

37-
To create a DSN, create (if necessary) and edit the file **~/.odbc.ini** (`.odbc.ini` in your home directory) for a User DSN only accessible to the current user, or `/etc/odbc.ini` for a System DSN (administrative privileges required.) The following is a sample file that shows the minimal required entries for a DSN:
39+
DSNs are optional. You can use a DSN to define connection string keywords under a `DSN` name that you can then reference in the connection string. To create a DSN, create (if necessary) and edit the file **~/.odbc.ini** (`.odbc.ini` in your home directory) for a User DSN only accessible to the current user, or `/etc/odbc.ini` for a System DSN (administrative privileges required.) The following is a sample file that shows the minimal required entries for a DSN:
3840

39-
```
41+
```ini
42+
# [DSN name]
4043
[MSSQLTest]
41-
Driver = ODBC Driver 13 for SQL Server
42-
Server = [protocol:]server[,port]
43-
#
44+
Driver = ODBC Driver 17 for SQL Server
45+
# Server = [protocol:]server[,port]
46+
Server = tcp:localhost,1433
47+
#
4448
# Note:
4549
# Port is not a valid keyword in the odbc.ini file
4650
# for the Microsoft ODBC driver on Linux or macOS
4751
#
4852
```
4953

54+
To connect using the above DSN in a connection string, you would specify the `DSN` keyword like: `DSN=MSSQLTest;UID=my_username;PWD=my_password`
55+
The above connection string would be the equivalent of specifying a connection string without the `DSN` keyword like: `Driver=ODBC Driver 17 for SQL Server;Server=tcp:localhost,1433;UID=my_username;PWD=my_password`
56+
5057
You can optionally specify the protocol and port to connect to the server. For example, **Server=tcp:**_servername_**,12345**. Note that the only protocol supported by the Linux and macOS drivers is `tcp`.
5158

5259
To connect to a named instance on a static port, use <b>Server=</b>*servername*,**port_number**. Connecting to a dynamic port is not supported before version 17.4.
5360

5461
Alternatively, you can add the DSN information to a template file, and execute the following command to add it to `~/.odbc.ini` :
5562
- **odbcinst -i -s -f** _template_file_
56-
63+
5764
You can verify that your driver is working by using `isql` to test the connection, or you can use this command:
5865
- **bcp master.INFORMATION_SCHEMA.TABLES out OutFile.dat -S <server> -U <name> -P <password>**
5966

6067
## Using TLS/SSL
68+
6169
You can use Transport Layer Security (TLS), previously known as Secure Sockets Layer (SSL), to encrypt connections to [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)]. TLS protects [!INCLUDE[ssNoVersion](../../../includes/ssnoversion-md.md)] user names and passwords over the network. TLS also verifies the identity of the server to protect against man-in-the-middle (MITM) attacks.
6270

6371
Enabling encryption increases security at the expense of performance.
@@ -73,7 +81,7 @@ Regardless of the settings for **Encrypt** and **TrustServerCertificate**, the s
7381

7482
By default, encrypted connections always verify the server's certificate. However, if you connect to a server that has a self-signed certificate, also add the `TrustServerCertificate` option to bypass checking the certificate against the list of trusted certificate authorities:
7583

76-
```
84+
```
7785
Driver={ODBC Driver 13 for SQL Server};Server=ServerNameHere;Encrypt=YES;TrustServerCertificate=YES
7886
```
7987

0 commit comments

Comments
 (0)