简体   繁体   中英

ODBC Connection String Problem

I am having major trouble connecting to my database via ODBC.

The db is local (but I have a mirror on a virtual machine), so I am trying to use the connectionstring:

Dsn=MonetDB;host=TARBELL

where TARBELL is the name of my computer. However, it doesn't connect. BUT, this string does:

Dsn=MonetDB;host=localhost

as does

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.

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. this is the conn string i'm using and is working for 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. You can see with 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. Some installations of MySQL listen on localhost only, so if you specify the computer name, they stop listening.

This behaviour is configured using the bind-address option:

--bind-address=127.0.0.1

Or the equivalent (MySQL also uses DNS to resolve hostnames):

--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:

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.

I've never seen a "host" parameter for a DSN type connection string. DSN 's are either stored with the user, the system or as a file. The way you have referenced your DSN here, it is either stored under your user account or with the system. With a DSN , all the credentials and information about which server and driver to be used are stored in the DSN . If you want control over those parameters, you should consider a DSN -less connection string like so:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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