>  기사  >  데이터 베이스  >  MySQL连接字符串的经验总结

MySQL连接字符串的经验总结

WBOY
WBOY원래의
2016-06-07 16:13:371312검색

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


성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.