MySQL连接字符串的经验总结

WBOY
发布: 2016-06-07 16:13:37
原创
1314 人浏览过

以下的文章主要向大家讲述的是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
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板