MySQL link string Various programs connect to a collection (including asp.net,c#, etc.)

Source: Internet
Author: User
Tags stmt ssl connection

One, MySQL connector/odbc 2.50 (MyODBC 2.50) connection mode

1, local database connection Driver={mysql}; Server=localhost;option=16834;database=mydatabase;

2, Remote data connection Driver={mysql}; server=myserveraddress;option=131072; stmt=;D atabase=mydatabase; User=myusername; Password=mypassword;

3. Special TCP/IP Port Connection Description: The default port for this driver is 3306. If not specifically indicated in the connection string is the 3306 port connected to MySQL. Driver={mysql}; server=myserveraddress; port=3306;option=131072; stmt=;D atabase=mydatabase; User=myusername; Password=mypassword;

Second, MySQL Connector/odbc 3.51 (MyODBC 3.51) connection mode

1, local Database connection Driver={mysql ODBC 3.51 Driver}; Server=localhost;database=mydatabase; User=myusername; password=mypassword;option=3;

2, Remote data connection Driver={mysql ODBC 3.51 Driver}; Server=data.domain.com;database=mydatabase; User=myusername; password=mypassword;option=3;

3. Special TCP/IP Port Connection Description: The default port for this driver is 3306. If not specifically indicated in the connection string is the 3306 port connected to MySQL. Driver={mysql ODBC 3.51 Driver}; server=data.domain.com; Port=3306;database=mydatabase; User=myusername; password=mypassword;option=3;

4, the connection of special character set Driver={mysql ODBC 3.51 Driver}; Server=data.domain.com;charset=utf8;database=mydatabase; User=myusername; password=mypassword;option=3;

Third, OLE DB, OleDbConnection (. NET) connection mode 1, standard connection Provider=mysqlprov;data source=mydb; User Id=myusername; Password=mypassword;

Iv. MySQL connector/net (. Net) connection mode

1. Standard connection (description, default port is 3306.) ) Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword;

2, the special TCP/IP port connection server=myserveraddress; Port=1234;database=mydatabase; Uid=myusername; Pwd=mypassword;

3, named pipe Description: The port value is-1, the description is connected by a named pipe. This method is only valid under Windows and is ignored under UNIX. server=myserveraddress; Port=-1;database=mydatabase; Uid=myusername; Pwd=mypassword;

4. A multi-server connection connects to the database in this way, without worrying about which database to use.

Server=serveraddress1 & ServerAddress2 & etc:;D Atabase=mydatabase; Uid=myusername; Pwd=mypassword;

5. Encryption option This active SSL connection encrypts data transfer for all clients and server providers. And the server must have a certificate. This option starts with the connector/net5.0.3 version, which is not available in previous versions.

server=myserveraddress; Port=-1;database=mydatabase; Uid=myusername; Pwd=mypassword;

6. Modify the default command time-out time to use this to modify the default command timeout for the connection. Note: This bar does not affect the time-out that you set on a separate command object. This section is only valid for versions connector/net 5.1.4 and above.

Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword;default command timeout=20;

7. Modify the connection test time Use this change the wait time (in seconds) to terminate retry and receive errors

Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword; Connection timeout=5;

8, inactivating prepared statementsuse this one to instruct the provider to ignore any command prepare statements and Preve NT corruption issues with server side prepared statements. This option is added to the Connector/net version 5.0.3 and 1.0.9.

Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword;ignore prepare=true;

9. Special TCP/IP port connection This statement modifies the port of the connection. The default port is 3306. This parameter is ignored by UNIX.

Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword; port=3306;

10, Special network protocol This statement modifies which protocol is used to connect. If not specifically stated, "socket" is the default value. "TCP" is the same as "socket". "Pipe" is connected using a named pipe, "UNIX" is using a UNIX socket connection, "Memory" is the use of MySQL shared memory.

Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword; Protocol=socket;

11. Connection to a special character set this statement indicates that the string encoding is sent to the query statement on the server. Note: The query results are still transmitted in the format of the reverse data.

Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword; Charset=utf8;

12. Modify the shared memory name this statement is used to modify the shared memory name used to communicate. Description: This statement is valid only if the Connection Agreement is set to "memory".

Server=myserveraddress;database=mydatabase; Uid=myusername; Pwd=mypassword; Shared Memory Name=mysql;

V. Mysqlconnection (. NET) connection mode

1, Einfodesigns.dbprovider

Data source=myserveraddress;database=mydatabase; User Id=myusername; Password=mypassword; Command Logging=false;

Vi. sevenobjects mysqlclient (. NET) connection mode

1. Standard connection

host=myserveraddress; Username=myusername; Password=mypassword;database=mydatabase;

Vii. 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 link string Various programs connect to a collection (including asp.net,c#, etc.)

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.