XNIU’s space

August 15, 2007

MySQL connection string

Filed under: Tech — xniu @ 12:16 pm

Some information about MySQL connection string for .NET driver (MsQL connector/NET):

For detail see: http://dev.mysql.com/doc/refman/5.0/en/connector-net-examples-mysqlconnection.html


– Persist Security Info=False; Username=user; Password=pass; database=test1; server=localhost; Connect Timeout=30

– database=myDB; server=/var/lib/mysql/mysql.sock; user id=myUser; pwd=myPass

Some points:

– The ConnectionString property can be set only when the connection is closed. Many of the connection string values have corresponding read-only properties. When the connection string is set, all of these properties are updated, except when an error is detected. In this case, none of the properties are updated.

– The connection string is parsed immediately after being set. If errors in syntax are found when parsing, a runtime exception, such as ArgumentException, is generated. Other errors can be found only when an attempt is made to open the connection.

– If a specific keyword in a keyword=value pair occurs multiple times in a connection string, the last occurrence listed is used in the value set.

– Keywords are not case sensitive.

Frequently used keyword:

– Server/Host/Data Source/Address/Addr: The name or network address of the instance of MySQL to which to connect. Default: localhost.

– Connect Timeout: The length of time (in seconds) to wait for a connection to the server before terminating the attempt and generating an error. Default: 15.

– Initial Catalog/Database: The name of the database to use intially. Default: mysql.

– User Id/Uid/User name/Username: The MySQL login account being used.

– Password/Pwd: The password for the MySQL account being used.

(P.S. Windows live writer really sucks!)


Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: