Connection Strings for SQL Server

Download Connectors from dev.MySQL.com

MySQL Connector/Net

Type: .NET Framework Class Library
Usage: MySql.Data.MySqlClient.MySqlConnection
Manufacturer: MySQL

Standard
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; 
Default port is 3306.

Specifying port
copyraw
Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
  1.  Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword; 

Named pipes
copyraw
Server=myServerAddress;Port=-1;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
  1.  Server=myServerAddress;Port=-1;Database=myDataBase;Uid=myUsername;Pwd=myPassword; 
It is the port value of -1 that tells the driver to use named pipes network protocol. This is available on Windows only. The value is ignored if Unix socket is used.

Multiple servers
Use this to connect to a server in a replicated server configuration without concern on which server to use.
copyraw
Server=serverAddress1 & serverAddress2 & etc..;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
  1.  Server=serverAddress1 & serverAddress2 & etc..;Database=myDataBase;Uid=myUsername;Pwd=myPassword; 

Using encryption
This one activates SSL encryption for all data sent between the client and server. The server needs to have a certificate installed.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Encryption=true;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Encryption=true
This option is available from Connector/NET version 5.0.3. In earlier versions, this option has no effect.

Using encryption, alternative
Some reported problems with the above one. Try replacing the key "Encryption" with "Encrypt" instead.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Encrypt=true;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Encrypt=true

Specifying default command timeout
Use this one to specify a default command timeout for the connection. Please note that the property in the connection string does not supercede the individual command timeout property on an individual command object.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;default command timeout=20;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;default command timeout=20
This option is available from Connector/NET version 5.1.4.

Specifying connection attempt timeout
Use this one to specify the length in seconds to wait for a server connection before terminating the attempt and receive an error.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Connection Timeout=5;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Connection Timeout=5

Inactivating prepared statements
Use this one to instruct the provider to ignore any command prepare statements and prevent corruption issues with server side prepared statements.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Ignore Prepare=true;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Ignore Prepare=true
The option was added in Connector/NET version 5.0.3 and Connector/NET version 1.0.9.

Specifying port
Use this one to specify what port to use for the connection.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Port=3306;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Port=3306
The port 3306 is the default MySql port. The value is ignored if Unix socket is used.

Specifying network protocol
Use this one to specify which network protocol to use for the connection.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; Protocol=socket;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; Protocol=socket; 
"socket" is the default value used if the key isn't specified. Value "tcp" is an equivalent for "socket". Use "pipe" to use a named pipes connection, "unix" for a Unix socket connection and "memory" to use MySQL shared memory.

Specifying character set
Use this one to specify which character set to use to encode queries sent to the server.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; CharSet=UTF8;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword; CharSet=UTF8; 
Note that resultsets still are returned in the character set of the data returned.

Specifying shared memory name
Use this one to specify the shared memory object name used for the communication.
copyraw
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Shared Memory Name=MYSQL;
  1.  Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Shared Memory Name=MYSQL; 
This one is applicable only when the connection protocol value is set to "memory".

eInfoDesigns.dbProvider

Type: .NET Framework Class Library
Usage: eInfoDesigns.dbProvider.MySqlClient.MySqlConnection
Manufacturer: eInfoDesigns

Standard
copyraw
Data Source=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Command Logging=false;
  1.  Data Source=myServerAddress;Database=myDataBase;User ID=myUsername;Password=myPassword;Command Logging=false

SevenObjects MySqlClient

Type: .NET Framework Class Library
Usage:
Manufacturer: SevenObjects

Standard
copyraw
Host=myServerAddress;UserName=myUsername;Password=myPassword;Database=myDataBase;
  1.  Host=myServerAddress;UserName=myUsername;Password=myPassword;Database=myDataBase; 

dotConnect for MySQL (former MyDirect.NET and Core Labs MySQLDirect.NET)

Type: .NET Framework Class Library
Usage: Devart.Data.MySql.MySqlConnection
Manufacturer: Devart

Standard
copyraw
User ID=root;Password=myPassword;Host=localhost;Port=3306;Database=myDataBase; Direct=true;Protocol=TCP;Compress=false;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0;
  1.  User ID=root;Password=myPassword;Host=localhost;Port=3306;Database=myDataBase; Direct=true;Protocol=TCP;Compress=false;Pooling=true;Min Pool Size=0;Max Pool Size=100;Connection Lifetime=0

MySQLDriverCS

Type: .NET Framework Class Library
Usage: MySQLDriverCS.MySQLConnection
Manufacturer: MySQLDriverCS project team

Standard
copyraw
Location=myServerAddress;Data Source=myDataBase;User ID=myUsername;Password=myPassword;Port=3306;Extended Properties="""";
  1.  Location=myServerAddress;Data Source=myDataBase;User ID=myUsername;Password=myPassword;Port=3306;Extended Properties=""""
This is a free simple .NET compliant MySQL driver. Project space at SourceForge.

MySQL OLEDB

Type: OLE DB Provider
Usage: Provider=MySQLProv
Manufacturer: MySQL

Standard
copyraw
Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;
  1.  Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword; 
Download Connectors from dev.MySQL.com

.NET Framework Data Provider for OLE DB

Type: .NET Framework Wrapper Class Library
Usage: System.Data.OleDb.OleDbConnection
Manufacturer: Microsoft

Bridging to MySQL OLEDB This is just one connection string sample for the wrapping OleDbConnection class that calls the underlying OLEDB provider. See respective OLE DB provider for more connection strings to use with this class.
copyraw
Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;
  1.  Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword; 

MyODBC 2.50

Type: ODBC Driver
Usage: Driver={mySQL}
Manufacturer: MySQL

Local database
copyraw
Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase;
  1.  Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase; 

Remote database
copyraw
Driver={mySQL};Server=myServerAddress;Option=131072;Stmt=;Database=myDataBase; User=myUsername;Password=myPassword;
  1.  Driver={mySQL};Server=myServerAddress;Option=131072;Stmt=;Database=myDataBase; User=myUsername;Password=myPassword; 

Specifying TCP/IP port
copyraw
Driver={mySQL};Server=myServerAddress;Port=3306;Option=131072;Stmt=; Database=myDataBase; User=myUsername;Password=myPassword;
  1.  Driver={mySQL};Server=myServerAddress;Port=3306;Option=131072;Stmt=; Database=myDataBase; User=myUsername;Password=myPassword; 
The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.

MySQL Connector/ODBC 3.51

Type: ODBC Driver
Usage: Driver={MySQL ODBC 3.51 Driver}
Manufacturer: MySQL

Local database
copyraw
Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 3.51 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3

Remote database
copyraw
Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Option=3

Specifying TCP/IP port
copyraw
Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3
The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.

Specifying character set
copyraw
Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;charset=UTF8;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;charset=UTF8;Database=myDataBase;User=myUsername; Password=myPassword;Option=3
Note that the charset option works from version 3.51.17 of the driver.

Specifying socket
This one specifies the Unix socket file or Windows named pipe to connect to. Used only for local client connections.
copyraw
Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Socket=MySQL;Option=3;
  1.  Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Socket=MySQL;Option=3
On Windows, the socket variable is the name of the named pipe that is used for local client connections. The default value is MySQL. On Unix platforms, the socket variable is the name of the socket file that is used for local client connections. The default is /tmp/mysql.sock.

Using SSL
copyraw
Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;sslca=c:\cacert.pem;sslcert=c:\client-cert.pem;sslkey=c:\client-key.pem;sslverify=1;Option=3;
  1.  Driver={MySQL ODBC 3.51 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;sslca=c:\cacert.pem;sslcert=c:\client-cert.pem;sslkey=c:\client-key.pem;sslverify=1;Option=3
SSLCA specifies the path to a file with a list of trust SSL CAs. SSLCERT specifies the name of the SSL certificate file to use for establishing a secure connection. SSLKEY specifies the name of the SSL key file to use for establishing a secure connection.

MySQL Connector/ODBC 5.1

Type: ODBC Driver
Usage: Driver={MySQL ODBC 5.1 Driver}
Manufacturer: MySQL

Local database
copyraw
Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3

Remote database
copyraw
Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Option=3

Specifying TCP/IP port
copyraw
Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Port=3306;Database=myDataBase;User=myUsername; Password=myPassword;Option=3
The driver defaults to port value 3306, if not specified in the connection string, as 3306 is the default port for MySQL.

Specifying character set
copyraw
Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;charset=UTF8;Database=myDataBase;User=myUsername; Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;charset=UTF8;Database=myDataBase;User=myUsername; Password=myPassword;Option=3

Specifying socket
This one specifies the Unix socket file or Windows named pipe to connect to. Used only for local client connections.
copyraw
Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Socket=MySQL;Option=3;
  1.  Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;Socket=MySQL;Option=3
On Windows, the socket variable is the name of the named pipe that is used for local client connections. The default value is MySQL. On Unix platforms, the socket variable is the name of the socket file that is used for local client connections. The default is /tmp/mysql.sock.

Using SSL
copyraw
Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;sslca=c:\cacert.pem;sslcert=c:\client-cert.pem;sslkey=c:\client-key.pem;sslverify=1;Option=3;
  1.  Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;User=myUsername; Password=myPassword;sslca=c:\cacert.pem;sslcert=c:\client-cert.pem;sslkey=c:\client-key.pem;sslverify=1;Option=3
SSLCA specifies the path to a file with a list of trust SSL CAs. SSLCERT specifies the name of the SSL certificate file to use for establishing a secure connection. SSLKEY specifies the name of the SSL key file to use for establishing a secure connection.

.NET Framework Data Provider for ODBC

Type: .NET Framework Wrapper Class Library
Usage: System.Data.Odbc.OdbcConnection
Manufacturer: Microsoft

Bridging to MySQL Connector/ODBC 5.1
This is just one connection string sample for the wrapping OdbcConnection class that calls the underlying ODBC Driver. See respective ODBC driver for more connection strings to use with this class.
copyraw
Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3;
  1.  Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase; User=myUsername;Password=myPassword;Option=3

Source: www.connectionstrings.com/mysql

Download Connectors from dev.MySQL.com

Category: SQL Server :: Article: 310

Credit where Credit is Due:


Feel free to copy, redistribute and share this information. All that we ask is that you attribute credit and possibly even a link back to this website as it really helps in our search engine rankings.

Disclaimer: The information on this website is provided without warranty and any content is merely the opinion of the author. Please try to test in development environments prior to adapting them to your production environments. The articles are written in good faith and, at the time of print, are working examples used in a commercial setting.

Thank you for visiting and, as always, we hope this website was of some use to you!

Kind Regards,

Joel Lipman
www.joellipman.com

Related Articles

Joes Revolver Map

Accreditation

Badge - Certified Zoho Creator Associate
Badge - Certified Zoho Creator Associate

Donate & Support

If you like my content, and would like to support this sharing site, feel free to donate using a method below:

Paypal:
Donate to Joel Lipman via PayPal

Bitcoin:
Donate to Joel Lipman with Bitcoin - Valid till 8 May 2022 3QnhmaBX7LQSRsC9hh6Je9rGQKEGNQNfPb
© 2021 Joel Lipman .com. All Rights Reserved.