MySQL Connection string Summary
1. Local Database connection
<connectionStrings>
<add name= "ConnectionString" connectionstring= "Server=localhost;option=16834;database=mydatabase" ProviderName = "MySql.Data.MySqlClient"/>
</connectionStrings>
2. Remote Data connection
server=myserveraddress;option=131072; stmt=;D atabase=mydatabase; User=myusername; Password=mypassword;>
3. Special TCP/IP port connection
server=myserveraddress; port=3306;option=131072; stmt=;D atabase=mydatabase; User=myusername; Password=mypassword;
4. Standard connection
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=;
Description: The default port for this driver is 3306. If not specifically indicated in the connection string is the 3306 port connected to MySQL.
The meaning of each character in the MYSQL link:
Parameter name |
Parameter description |
Default value |
Minimum version requirements |
User |
Database user name (used to connect to database) |
|
All versions |
Password |
User password (used to connect to database) |
|
All versions |
Useunicode |
If the Unicode character set is used, the value of this parameter must be set to True if the parameter characterencoding is set to gb2312 or GBK |
False |
1.1g |
Characterencoding |
When Useunicode is set to True, the character encoding is specified. For example, can be set to gb2312 or GBK |
False |
1.1g |
AutoReConnect |
Is the connection automatically reconnected when the database connection is interrupted abnormally? |
False |
1.1 |
Autoreconnectforpools |
Whether to use a reconnection policy for database connection pooling |
False |
3.1.3 |
Failoverreadonly |
Is the connection set to read-only after the automatic reconnection is successful? |
True |
3.0.12 |
Maxreconnects |
When AutoReConnect is set to true, the number of times to retry the connection |
3 |
1.1 |
Initialtimeout |
When AutoReConnect is set to true, the time interval between two re-interconnects, in seconds |
2 |
1.1 |
ConnectTimeout |
Time-out, in milliseconds, when establishing a socket connection with the database server. 0 means never timeout, for JDK 1.4 and later |
0 |
3.0.1 |
Sockettimeout |
Socket operation (Read-write) timeout, in milliseconds. 0 means never time out |
0 |
3.0.1 |
MYSQL Link String