Heim >Datenbank >MySQL-Tutorial >MySQL连接字符串的经验总结

MySQL连接字符串的经验总结

WBOY
WBOYOriginal
2016-06-07 16:13:371341Durchsuche

以下的文章主要向大家讲述的是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连接字符串总结的部分内容描述,希望会给你带来一些帮助在此方面。


Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn