Tuesday, July 10, 2012

Connection strings for MySQL

Standard

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

Specifying port

Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;

Named pipes

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.
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.
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.
Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Encrypt=true;

Share : Connection strings for MySQL

Related Posts

Connection strings for MySQL
4/ 5
Oleh