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

MySQL Connection String Samples(5)

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

Location = myServerAddress ; Data Source = myDataBase ; User ID = myUsername ; Password = myPassword ; Port = 3306 ; Extended Properties = """" ; MySQL OLEDB More info and provider downloads Set exam

Location=myServerAddress;Data Source=myDataBase;User ID=myUsername;Password=myPassword;
Port=3306;Extended Properties="""";

 

 

MySQL OLEDB

More info and provider downloads

Set example values

Standard

Provider=MySQLProv;Data Source=mydb;User Id=myUsername;Password=myPassword;

 

 

.NET Framework Data Provider for OLE DB

More info and wrapper class library downloads

Set example values

Use an OLE DB provider from .NET

Provider=any oledb provider's name;OledbKey1=someValue;OledbKey2=someValue;

See the respective OLEDB provider's connection strings options. The .net OleDbConnection will just pass on the connection string to the specified OLEDB provider. Read more here.

 

 

MyODBC 2.50

More info and driver downloads

Set example values

Local database

Driver={mySQL};Server=localhost;Option=16834;Database=myDataBase;

 

 

Remote database

Driver={mySQL};Server=myServerAddress;Option=131072;Stmt=;Database=myDataBase;
User=myUsername;Password=myPassword;

 

 

Specifying TCP/IP port

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

More info and driver downloads

Set example values

Local database

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

 

 

Remote database

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

 

 

Specifying TCP/IP port

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

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.

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

mysql教程阅读排行

最新文章