In the previous article, we gave a detailed introduction to the practical operation experience and practical operation skills of MySQL connection strings, this article mainly introduces the actual operation steps of MySQL connection strings in practice.
MySQL connection string: MySQL Connector/Net (. NET) Connection Method
1. Standard connection (the default port is 3306 .)
- Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
2. Special TCP/IP Port connection
- Server=myServerAddress;Port=1234;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
3. Named Pipe
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.
- Server=myServerAddress;Port=-1;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
4. multi-server connection
You do not have to worry about which database to connect.
- Server=serverAddress1 & serverAddress2 & etc..;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
5. Encryption options
This active SSL connection encrypts data transmission between all clients and server vendors. The server must have a certificate.
This option is available from Connector/NET5.0.3, which is unavailable in previous versions.
- Server=myServerAddress;Port=-1;Database=myDataBase;Uid=myUsername;Pwd=myPassword;
6. 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.
This entry is only valid for Connector/NET 5.1.4 and later versions.
- Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;default command timeout=20;
7. Modify the connection time
Use this modification to terminate the retry and receive the error wait time (in seconds)
- Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Connection Timeout=5;
8. Inactivating prepared statements
Use this one to instruct the provider to ignore any command prepare statements and prevent upload uption issues with server side prepared statements.
This option is added to the 5.0.3 and 1.0.9 versions of Connector/NET.
- Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Ignore Prepare=true;
9. Special TCP/IP Port connection
This statement modifies the connected port.
The default port is 3306. This parameter is ignored by Unix.
- Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Port=3306;
10. Special network protocols
This statement modifies the protocol used for connection.
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.
- Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Protocol=socket;
11. Special Character Set connection
This statement indicates the query statement that sends the encoding string to the server.
Note: The query results are still transmitted in reverse data format.
- Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;CharSet=UTF8;
12. Modify the shared memory name
This statement is used to modify the name of the shared memory used for communication.
Note: This statement is valid only when the connection protocol is set to "memory.
- Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;Shared Memory Name=MySQL;
MySQL connection string: MySQLConnection (. NET) Connection Method
1. eInfoDesigns. dbProvider
- Data Source=myServerAddress;Database=myDataBase;
User ID=myUsername;Password=myPassword;Command Logging=false;
SevenObjects MySQLClient (. NET) Connection Method
1. Standard connection
- Host=myServerAddress;UserName=myUsername;Password=myPassword;Database=myDataBase;
Core Labs MySQLDirect (. NET) Connection Method
1. 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=0;
MySQL connection string: MySQLDriverCS (. NET) Connection Method
1. Standard connection
- Location=myServerAddress;Data Source=myDataBase;User ID=myUsername;
Password=myPassword;Port=3306;Extended Properties="""";
The above content is an introduction to the MySQL connection string, and I hope you will get something.