当前位置:首页 > 开发教程 > mysql教程 >

MySQL Connection String Samples(6)

时间:2013-04-24 22:49 来源:网络整理 作者:采集侠 收藏

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:\c

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

More info and driver downloads

Set example values

Local database

Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase;User=myUsername;
Password=myPassword;Option=3;

 

 

On 64 bit machine

It seems we need to point on MSDASQL for the (32 bit) ODBC driver to work on 64 bit machines.

Provider=MSDASQL;Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=myDataBase;
User=myUsername;Password=myPassword;Option=3;

 

 

64 bit version of the driver

Note the "w" in the driver name.

Driver={MySQL ODBC 5.2w Driver};Server=localhost;Database=myDataBase;User=myUsername;
Password=myPassword;Option=3;

 

 

Remote database

Driver={MySQL ODBC 5.1 Driver};Server=myServerAddress;Database=myDataBase;
User=myUsername;Password=myPassword;Option=3;

 

 

Specifying TCP/IP port

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

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.

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

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

More info and wrapper class library downloads

Set example values

Use an ODBC driver from .NET

Driver={any odbc driver's name};OdbcKey1=someValue;OdbcKey2=someValue;

See the respective ODBC driver's connection strings options. The .net OdbcConnection will just pass on the connection string to the specified ODBC driver. Read more here.

 

 


mysql教程阅读排行

最新文章