MySql connection string Summary

Source: Internet
Author: User
Tags mysql connection string ssl connection

MySQL Connector/ODBC 2.50 (MyODBC 2.50) Connection Mode
Local Database Connection
The syntax format is as follows:

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

The following syntax format is used for remote data connection:

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

Special TCP/IP Port connection
The syntax format is as follows:

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

Note: The default port of this Driver is 3306. If it is not specified in the connection string, port 3306 is connected to Mysql.
MySQL Connector/ODBC 3.51 (MyODBC 3.51) Connection Mode
Local Database Connection
The syntax format is as follows:

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

The following syntax format is used for remote data connection:

Driver = {MySQL ODBC 3.51 Driver}; Server = data.domain.com; Database = myDataBase; User = myUsername; Password = myPassword; Option = 3;

Special TCP/IP Port connection
The syntax format is as follows:

Driver = {MySQL ODBC 3.51 Driver}; Server = data.domain.com; Port = 3306; Database = myDataBase; User = myUsername; Password = myPassword; Option = 3;

Note: The default port of this Driver is 3306. If it is not specified in the connection string, port 3306 is connected to Mysql.
Special Character Set connection
The syntax format is as follows:

Driver = {MySQL ODBC 3.51 Driver}; Server = data.domain.com; charset = UTF8; Database = myDataBase; User = myUsername; Password = myPassword; Option = 3;

Ole db, OleDbConnection (. NET) Connection Method
Standard connection
The syntax format is as follows:

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

MySQL ctor/Net (. NET) Connection Method
Standard connection
The syntax format is as follows:

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

The default port is 3306.
Special TCP/IP Port connection
The syntax format is as follows:

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

Named Pipe
The syntax format is as follows:

Server = myServerAddress; Port =-1; Database = myDataBase; Uid = myUsername; Pwd = myPassword;

Note: If the port value is-1, the connection is established using the named pipe. This method is only valid in Windows and is ignored in UNIX.
Multi-server connection
You do not have to worry about which database to connect.
The syntax format is as follows:

Server = serverAddress1 & serverAddress2 & etc ..; Database = myDataBase; Uid = myUsername; Pwd = myPassword;

Encryption options
This active SSL connection encrypts data transmission between all clients and server vendors. The server must have a certificate.
The syntax format is as follows:

Server = myServerAddress; Port =-1; Database = myDataBase; Uid = myUsername; Pwd = myPassword;

This option is available from Connector/NET5.0.3, which is unavailable in previous versions.
Modify the default command timeout time
Use this command to modify the default connection timeout time. Note: This does not affect the timeout value you set on a single command object. The syntax format is as follows:

Server = myServerAddress; Database = myDataBase; Uid = myUsername; Pwd = myPassword; default command timeout = 20;

This entry is only valid for Connector/NET 5.1.4 and later versions.
Modify the connection time
The following syntax format is used to modify the wait time (in seconds) for terminating retry and receiving errors:

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 resume uption issues with server side prepared statements. the syntax format is as follows:

Server = myServerAddress; Database = myDataBase; Uid = myUsername; Pwd = myPassword; Ignore Prepare = true;
This option is added to the 5.0.3 and 1.0.9 versions of Connector/NET.
Special TCP/IP Port connection
This statement modifies the connected port.
The syntax format is as follows:

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

The default port is 3306. This parameter is ignored by Unix.
Special Network Protocol
This statement modifies the protocol used for connection. The syntax format is as follows:

Server = myServerAddress; Database = myDataBase; Uid = myUsername; Pwd = myPassword; Protocol = socket;

Unless otherwise specified, "socket" is the default value. "Tcp" is of the same significance as "socket. "Pipe" uses named pipe connections, "unix" uses unix socket connections, and "memory" uses mySql shared memory.
Special Character Set connection
This statement indicates the query statement that sends the encoding string to the server.
The syntax format is as follows:

Server = myServerAddress; Database = myDataBase; Uid = myUsername; Pwd = myPassword; CharSet = UTF8;

Note: The query results are still transmitted in reverse data format.
Modify the shared memory name
This statement is used to modify the name of the shared memory used for communication. The syntax format is as follows:

Server = myServerAddress; Database = myDataBase; Uid = myUsername; Pwd = myPassword; Shared Memory Name = MYSQL;

Note: This statement is valid only when the connection protocol is set to "memory.
MySqlConnection (. NET) Connection Method
The following syntax formats are supported:

Data Source = myServerAddress; Database = myDataBase; User ID = myUsername; Password = myPassword; Command Logging = false;

SevenObjects MySqlClient (. NET) Connection Method
Standard connection
The syntax format is as follows:

Host = myServerAddress; UserName = myUsername; Password = myPassword; Database = myDataBase;

Core Labs MySQLDirect (. NET) Connection Method
Standard connection
The syntax format is as follows:

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 (. NET) Connection Method
Standard connection
The syntax format is as follows:

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.