ホームページ > データベース > mysql チュートリアル > MySQL连接字符串的经验总结

MySQL连接字符串的经验总结

WBOY
リリース: 2016-06-07 16:13:37
オリジナル
1341 人が閲覧しました

以下的文章主要向大家讲述的是MySQL连接字符串的经验总结,如果你对MySQL连接字符串相关的实际操作有兴趣的话,你就可以对以下的文章点击观看了。希望会给你带来一些帮助在此方面。 一、MySQL Connector/ODBC 2.50 (MyODBC 2.cv50)连接方式 1、本地数据库连

以下的文章主要向大家讲述的是MySQL连接字符串的经验总结,如果你对MySQL连接字符串相关的实际操作有兴趣的话,你就可以对以下的文章点击观看了。希望会给你带来一些帮助在此方面。
 

一、MySQL Connector/ODBC 2.50 (MyODBC 2.cv50)连接方式

1、本地数据库连接

<ol class="dp-xml"><li class="alt"><span><span class="attribute">Driver</span><span>={MySQL};</span><span class="attribute">Server</span><span>=</span><span class="attribute-value">localhost</span><span>;</span><span class="attribute">Option</span><span>=</span><span class="attribute-value">16834</span><span>;</span><span class="attribute">Database</span><span>=</span><span class="attribute-value">myDataBase</span><span>; </span></span></li></ol>
ログイン後にコピー

2、远程数据连接

<ol class="dp-xml"><li class="alt"><span><span class="attribute">Driver</span><span>={MySQL};</span><span class="attribute">Server</span><span>=</span><span class="attribute-value">myServerAddress</span><span>;</span><span class="attribute">Option</span><span>=</span><span class="attribute-value">131072</span><span>;</span><span class="attribute">Stmt</span><span>=;</span><span class="attribute">Database</span><span>=</span><span class="attribute-value">myDataBase</span><span>; </span><span class="attribute">User</span><span>=</span><span class="attribute-value">myUsername</span><span>;</span><span class="attribute">Password</span><span>=</span><span class="attribute-value">myPassword</span><span>; </span></span></li></ol>
ログイン後にコピー

3、特殊的TCP/IP端口连接

说明:此Driver的默认端口是3306。如果没有在 MySQL连接字符串中特别指出就是连接MySQL的3306端口。

<ol class="dp-xml"><li class="alt"><span><span class="attribute">Driver</span><span>={MySQL};</span><span class="attribute">Server</span><span>=</span><span class="attribute-value">myServerAddress</span><span>;</span><span class="attribute">Port</span><span>=</span><span class="attribute-value">3306</span><span>;<br></span><span class="attribute">Option</span><span>=</span><span class="attribute-value">131072</span><span>;</span><span class="attribute">Stmt</span><span>=;</span><span class="attribute">Database</span><span>=</span><span class="attribute-value">myDataBase</span><span>; </span><span class="attribute">User</span><span>=</span><span class="attribute-value">myUsername</span><span>;</span><span class="attribute">Password</span><span>=</span><span class="attribute-value">myPassword</span><span>; </span></span></li></ol>
ログイン後にコピー

二、MySQL Connector/ODBC 3.51 (MyODBC 3.51)连接方式

1、本地数据库连接

<ol class="dp-xml"><li class="alt"><span><span class="attribute">Driver</span><span>={MySQL ODBC 3.51 Driver};</span><span class="attribute">Server</span><span>=</span><span class="attribute-value">localhost</span><span>;<br></span><span class="attribute">Database</span><span>=</span><span class="attribute-value">myDataBase</span><span>; </span><span class="attribute">User</span><span>=</span><span class="attribute-value">myUsername</span><span>;</span><span class="attribute">Password</span><span>=</span><span class="attribute-value">myPassword</span><span>;</span><span class="attribute">Option</span><span>=</span><span class="attribute-value">3</span><span>; </span></span></li></ol>
ログイン後にコピー

2、远程数据连接

<ol class="dp-xml"><li class="alt"><span><span class="attribute">Driver</span><span>={MySQL ODBC 3.51 Driver};</span><span class="attribute">Server</span><span>=</span><span class="attribute-value">data</span><span>.domain.com;<br></span><span class="attribute">Database</span><span>=</span><span class="attribute-value">myDataBase</span><span>;</span><span class="attribute">User</span><span>=</span><span class="attribute-value">myUsername</span><span>; </span><span class="attribute">Password</span><span>=</span><span class="attribute-value">myPassword</span><span>;</span><span class="attribute">Option</span><span>=</span><span class="attribute-value">3</span><span>; </span></span></li></ol>
ログイン後にコピー

3、特殊的TCP/IP端口连接

说明:此Driver的默认端口是3306。如果没有在 MySQL连接字符串中特别指出就是连接MySQL的3306端口。

<ol class="dp-xml"><li class="alt"><span><span class="attribute">Driver</span><span>={MySQL ODBC 3.51 Driver};</span><span class="attribute">Server</span><span>=</span><span class="attribute-value">data</span><span>.domain.com;</span><span class="attribute">Port</span><span>=</span><span class="attribute-value">3306</span><span>;<br></span><span class="attribute">Database</span><span>=</span><span class="attribute-value">myDataBase</span><span>;</span><span class="attribute">User</span><span>=</span><span class="attribute-value">myUsername</span><span>; </span><span class="attribute">Password</span><span>=</span><span class="attribute-value">myPassword</span><span>;</span><span class="attribute">Option</span><span>=</span><span class="attribute-value">3</span><span>; </span></span></li></ol>
ログイン後にコピー

4、特殊字符集的连接

<ol class="dp-xml"><li class="alt"><span><span class="attribute">Driver</span><span>={MySQL ODBC 3.51 Driver};</span><span class="attribute">Server</span><span>=</span><span class="attribute-value">data</span><span>.domain.com;<br></span><span class="attribute">charset</span><span>=</span><span class="attribute-value">UTF8</span><span>;</span><span class="attribute">Database</span><span>=</span><span class="attribute-value">myDataBase</span><span>;</span><span class="attribute">User</span><span>=</span><span class="attribute-value">myUsername</span><span>; </span><span class="attribute">Password</span><span>=</span><span class="attribute-value">myPassword</span><span>;</span><span class="attribute">Option</span><span>=</span><span class="attribute-value">3</span><span>; </span></span></li></ol>
ログイン後にコピー

三、OLE DB, OleDbConnection (.NET)连接方式

1、标准连接

<ol class="dp-xml"><li class="alt"><span><span class="attribute">Provider</span><span>=</span><span class="attribute-value">MySQLProv</span><span>;Data </span><span class="attribute">Source</span><span>=</span><span class="attribute-value">mydb</span><span>;User </span><span class="attribute">Id</span><span>=</span><span class="attribute-value">myUsername</span><span>;</span><span class="attribute">Password</span><span>=</span><span class="attribute-value">myPassword</span><span>; </span></span></li></ol>
ログイン後にコピー

上述的相关内容就是对 MySQL连接字符串总结的部分内容描述,希望会给你带来一些帮助在此方面。


ソース:php.cn
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。
最新の問題
人気のチュートリアル
詳細>
最新のダウンロード
詳細>
ウェブエフェクト
公式サイト
サイト素材
フロントエンドテンプレート