简体   繁体   English

ODBC连接字符串问题

[英]ODBC Connection String Problem

I am having major trouble connecting to my database via ODBC. 我通过ODBC连接到我的数据库时遇到了很大的麻烦。

The db is local (but I have a mirror on a virtual machine), so I am trying to use the connectionstring: db是本地的(但我在虚拟机上有镜像),所以我尝试使用connectionstring:

Dsn=MonetDB;host=TARBELL DSN = MonetDB宿主=塔贝尔

where TARBELL is the name of my computer. TARBELL是我电脑的名称。 However, it doesn't connect. 但是,它没有连接。 BUT, this string does: 但是,这个字符串:

Dsn=MonetDB;host=localhost DSN = MonetDB宿主=本地主机

as does 同样如此

Dsn=MonetDB DSN = MonetDB

Can anyone explain this? 有谁能解释一下? I am at a complete loss. 我完全失去了。

I have taken down my firewalls (at least until I get this figured out), so that can't be the problem. 我取下了我的防火墙(至少直到我弄明白这一点),所以这不是问题所在。

I eventually want to change the TARBELL to the mirrored virtual machine running another instance of the database. 我最终想要将TARBELL更改为运行另一个数据库实例的镜像虚拟机。

Many thanks, Brett 非常感谢,布雷特

我可以向connectionstrings.com推荐有关所有受支持的ADO.NET提供程序支持的语法的详细信息。

figured i'd post an answer to this here since i found this while searching for a windows monetdb connection string. 想我在这里发布了一个答案,因为我在搜索windows monetdb连接字符串时发现了这个问题。 this is the conn string i'm using and is working for monetdb 5: 这是我正在使用的conn字符串,并且正在为monetdb 5工作:

DRIVER=MonetDB ODBC Driver;PORT=50000;HOST=<your host>;DATABASE=<your db>;UID=monetdb;PWD=monetdb

DNS usually resolves TARBALL and localhost differently. DNS通常以不同方式解析TARBALLlocalhost You can see with ping: 你可以看到ping:

c:\>ping tarball
Pinging tarball [192.168.1.99] with 32 bytes of data:
                 ^^^^^^^^^^^^

c:\>ping localhost
Pinging tarball [127.0.0.1] with 32 bytes of data:
                 ^^^^^^^^^

The computer name resolves to the external IP, while localhost resolves to the special IP 127.0.0.1 that always points at the local machine. 计算机名称解析为外部IP,而localhost解析为始终指向本地计算机的特殊IP 127.0.0.1。 Some installations of MySQL listen on localhost only, so if you specify the computer name, they stop listening. MySQL的某些安装仅在localhost上侦听,因此如果您指定计算机名称,它们将停止侦听。

This behaviour is configured using the bind-address option: 使用bind-address选项配置此行为:

--bind-address=127.0.0.1

Or the equivalent (MySQL also uses DNS to resolve hostnames): 或等效(MySQL也使用DNS来解析主机名):

--bind-address=localhost 

To make the server listen on all interfaces, specify: 要使服务器侦听所有接口,请指定:

--bind-address=0.0.0.0

On Windows, MySQL reads configuration options from: 在Windows上,MySQL从以下位置读取配置选项:

WINDIR\my.ini, WINDIR\my.cnf
C:\my.ini, C:\my.cnf
INSTALLDIR\my.ini, INSTALLDIR\my.cnf

See the MySQL manual pages for some more information. 有关更多信息,请参见MySQL手册页

I've never seen a "host" parameter for a DSN type connection string. 我从未见过DSN类型连接字符串的“host”参数。 DSN 's are either stored with the user, the system or as a file. DSN可以与用户,系统一起存储,也可以作为文件存储。 The way you have referenced your DSN here, it is either stored under your user account or with the system. 您在此处引用DSN的方式,可以存储在您的用户帐户下,也可以存储在系统中。 With a DSN , all the credentials and information about which server and driver to be used are stored in the DSN . 使用DSN ,有关要使用的服务器和驱动程序的所有凭据和信息都存储在DSN If you want control over those parameters, you should consider a DSN -less connection string like so: 如果要控制这些参数,则应考虑使用DSN无连接字符串,如下所示:

"Driver={Mysql}; Server=[server_name];Port=[port_number]; Database=[database_name];UID=[username]; PWD=[password]"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM