• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1054
  • Last Modified:

Connection to MySQL (3.51) fail

Program (which is made using vs 2010) should take connection to intranet -server where
mysql database is located.
I've installed mysql-connector-odbc-3.51.28-winx64 to client computer and
connectionstring is:
"Driver={MySQL ODBC 3.51 Driver} ;Server=intraServer ;Port=3306;Option=3;Stmt=;Database=mydatabase;UID=root;"

But.. this connectionstring works if program is installed to windows 7 32bit but not using windows 7 64bit.

Does it matter that database -server is windows 2000 32bit?
  • 3
  • 2
2 Solutions
Only the driver that you install needs to be specific to the operating system platform. Install the 32-bit connector for installation on 32-bit Windows and the 64-bit one for the 64-bit version.

Secondly, you also need to make sure that when you create the data source that you are creating it in the 64-bit ODBC repo (settings are stored in the registry of which 64-bit Windows machines have two, a 32-bit one and the 64-bit one). Depending on the platform of the application trying to use the data source (32 or 64) it will try access to corresponding registry. It will always work on 32-bit Windows cause the data source will only ever be created in one registry, the 32-bit one.
To clarify some more, to access the 64-bit registry use C:\Windows\regedit.exe to access the 32-bit registry use C:\Windows\SysWOW64\regedit.exe

On the 64-bit system that cannot connect to the database, check if the application is running as a 32-bit application or a 64-bit one. (* 32 next to the process in Task Manager means it 32-bit).

Depending on the architecture it's using, go to the registry version in question and look for the key: HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI If you don't see a sub key there with the name of your data source then your app is not finding it either. You can easily export the key and just import into the other registry to make life easier.

Welcome to the wacky world of 64-bit hybrid operating systems!
d0nMaTTiAuthor Commented:
"..wacky world of 64-bit .." indeed.

My computer is win 7 home pre 64 bit and
I created system dsn link (control panel-->admin.tool --> ODBC)  and connection to local database seems to be correct. Then I did put "Dsn=myDNSTes;Uid=root" to odbc-connectionstring.
When I tested query using that connection it takes more than 20 secons running simpe sql-query.

Same query using sqlyog - takes 0,02 second. This is amazing.

And after this ... every querys from program (using System.Data.Odbc -library) takes times
but under sqlyog everything works fine.
Is this  associated with windwos 64-bit registry.

Before dns -testing HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI had not sub key and queries
works fine. After testing I found sub key Data Source...
I removed it but it had't  effect.

Is there simple way to restore/clear odbc-settings to original.

SQLyog will be using it's own native connection protocol which will be fast. Your app will be going through ODBC which is a generic driver and more than likely opening a connection for each call (where SQLyog just keeps on open) which will be considerably slower.

It's beyond me why your queries are taking THAT long though but I doubt it's anything to do with the fact that you are running on a 64-bit OS. I would also stick to the ODBC control panel to configure your connections.

But it sounds like your connection is working now, so the performance issue would be another problem altogether.
d0nMaTTiAuthor Commented:
Now connection works but it's overly complicated way
when need to edit registry.

Thansk a lot for advices.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now