MySQL ODBC connections (again) - mysql

I know this question has been asked many times but my variation is slightly different and I'm pulling my hair out after spending several hours trying to get one line of code to work. I have a MySQL database and am trying to connect using ODBC. I'm on Windows 10 version 1909.
Line 13: OpenString ="DRIVER={MySQL ODBC 8.0 ANSI Driver};SERVER=localhost;DATABASE=collections;UID=edited_out;PWD=edited_out;"
Line 14: Conn = Server.Createobject("ADODB.Connection")
Line 15: Conn.open = OpenString
The code quoted works fine on my main PC with Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0 and DRIVER={MySQL ODBC 5.3 ANSI Driver}. On the test PC with an almost identical configuration, the exact same code with the exception of the driver name fails. (Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0 and DRIVER={MySQL ODBC 8.0 ANSI Driver} or, for that matter, DRIVER={MySQL ODBC 8.0 Unicode Driver} - both installed.) Please see the attached image for evidence. I get the well-known and depressing "Data source name not found and no default driver specified". Code snippet and drivers
I realise that this error is almost always due to getting the driver name wrong. However, I've checked and rechecked my syntax and the driver installation. I know there's nothing obviously wrong with my ODBC installation since I installed LibreOffice purely for testing and was able to connect to the same database via ODBC within seconds on the same PC using the same driver shown here. Is there something different or particularly troublesome about the ODBC version 8.0 drivers? Do I need to try to downgrade this one to 5.3?
Thanks for any help.

FIX: Disable 32 bit applications for your site if working with 64 bit!
(Answering my own question in the hope that it helps somebody.) I figured it out. The connection string was a red herring. Further detective work led me to a post that advised checking application pools in IIS. The advice was to enable 32 bit applications under Advanced Settings for your site if you have any 32 bit applications, which is fairly obvious.
However, my application is 64 bit and I noticed that this option was DISABLED on my working PC. Disabling it on the other PC restored the connection: evidently Windows was defaulting to a nonexistent 32 bit driver and showing an ambiguous error message when this failed. Software writers seem to dig a lot of these holes for users to fall into...

Related

Problem Connecting SQLServer2016x64 using LinkedServer to MySqlx32

Problem Connecting SQLServer2016x64 using LinkedServer to MySqlx32
I'm migrating a working system from Windows2003x32 with SQL2005x32 and MySqlx32 to Win2012R2x64 with SQL2016SP3x64 and MySqlx32
on the old system back I am still sucesfully using LinkedServer to read and write to MySql from SQL. With MySql ODBC 3.51 Dreiver.
On the new server I tryed a bunch of options all resulting in DSN architecture mismatch.
What I did:
I installed MySql-connector-odbc-3.51.30-win64 (later I tryed v5.1.13 and 5.3.14 both 32 and 64 versions)
Using odbcad32.exe from System32 and/or SysWOW64 (tryed both) I sucefully added under System DSN the datasource and tested Ok.
From SQLServerManager I tryed to add linked server using
EXEC master.dbo.sp_addlinkedserver #server='SVTPASS', #srvproduct='SVTPASS', #datasrc='SVTPASS',
#provider='MSDASQL',
#provstr='DRIVER={MySQL ODBC 3.51 Driver}; SERVER=LOCALHOST; Port=3333; USER=******; PASSWORD=********; OPTION=3; DATABASE=svt_fpc_auth'
later tryed using "DRIVER={MySQL ODBC 5.3 Driver}" and "DRIVER={MySQL ODBC 5.3 Unicode Driver}"
But the strange thing is that whatever I try, even writing nonsense at DRIVER={} the same architecture mismatch error I get.
When testing the connection of linked server I recieve the following error:
"[Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application"
where am I doing it wrong?
I know that I'm trying to acess a 32bit MySql from 64bit SQLServer but there should be a solution.
I read many forum posts about this issue and tryed a few options suggested here and there, but I'm confused and and I don/t even know now what combinations I tryed and what I didn't tryed yet.
Can someone help with at least telling what are the right weapons to use to fight this issue...
Thanks in andvance
I solved my own problem
I new that I had to create the DSN from 64 version of odbcad32 but
The problem was that I was trying to launch odbcad32.exe from SysWOW64 folder but it launched an created the DSN in 32 bit state. Only when I launched it from windows apps it worked and created the DSN in 64 bit.
thanks aniway
I don't know what to do with this thread/question in this case. please advise

Delphi 11.1's FireDAC and MySQL: SSL connection error: unknown error number

Ok, I've spent all day on this, and I am stuck, so I'm going to ask for help.
I previously installed Delphi 11 Enterprise in a virtual machine, and also installed MySQL 8.0.27 (64-bit). After obtaining some 32-bit MySQL dlls I was able to easily connect to my database using the FireDAC MySQL driver and from the Data Explorer in the Delphi IDE.
I have now created a new VM and installed both Delphi 11.1 Enterprise and MySQL 8.0.28. After exporting my database from the previous VM, and importing it into this new MySQL server, I tried to attach to the database using FireDAC. Using the same parameters as in the last VM, and the same dlls copied to C:\Windows\SysWOW64, testing the connection fails and produces the following error:
[FireDAC][Phys][MySQL] SSL connection error: unknown error number
I've compared the parameters for connecting to the two databases between the two VMs, and they are the same. And, the connections in MySQL to the two databases also appear to be the same.
One thing that is odd (and I think I know why) is that in the VM where the connection fails, if I view the Info tab of the FireDAC Connection Editor, it says it is using libmysql.dll in the c:\Windows\System32 folder (there's no such file in that folder). But that is also true from the Connection Editor in the VM where FireDAC successfully connects, so I am assuming that System32 is being mapped to C:\Windows\SysWOW64.
If anyone can affirm that they are successfully connecting to MySQL 8... using Delphi 11.1 and FireDAC, and can offer a suggestion for what I need to fix, I will be grateful.
= = = = = = = = = = = = == = = = = = = = =
Update: I've uninstalled MySQL 8.0.28, and reinstalled it using the Development Computer template. I still cannot connect to MySQL using the FireDAC Connection Editor, but I can connect at runtime so long as I employ an FDPhysMySQLDriverLink component, and set the VendorLib property to either libmariadb.dll or libmysql.dll, the 32-bit versions that are stored in the C:\Windows\SysWOW64 folder (thanks Ian Barker for your sample code!). I'm still working on this, since I really want to connect from the IDE, but at least I've had some success.
I have had the same issue today, as part of a whole batch of problems with mysql not running so I updated it and then hit the error above.
My 64 bit Delphi 10.3 Programs would not connect at all - so I changed the physical driver to libmariadb.dll and that has resolved the issue.
Be sure from where your app is loading the libmysql.dll by calling h:= loadlibray('libmysql.dll') /without path/ and then GetModulePath(h) to see its full path.
Remember that Delphi is 32bit and it needs to use 32bit version of lobmysql.dll while a 64bit compiled program would need the same bitbness.
This was nuts. I installed and uninstalled MySQL (and MySQL Workbench and MySQL Script) probably 10 times. The last install worked. I have no idea why this was necessary.

Linking MySQL to MS SQL Server using OBDC Drivers (Error 7303)

I am trying to make a link between MySQL and MSSQL databases using ODBC Drivers. The reason is that our website is built using PHP and MySQL and we need to manage the database from SQL Server Manag. Studio.
I have already linked MySQL to MS ACCESS, so MySQL ODBC drivers are fully working.
When I try to link them from MICROSOFT SQL SERVER MANAGEMENT STUDIO > SERVER OBJECTS > LINKED SERVERS > NEW LINKED SERVER...
With this configuration:
I get this error:
I have tried with all these versions of MySQL OBDC Drivers:
ODBC 5.3 Unicode (32-bit) - This one is the one working with MS ACCESS
ODBC 5.3 ANSI (32-bit)
ODBC 5.3 Unicode (64-bit)
ODBC 5.3 ANSI (64-bit)
ODBC 8.0 Unicode (64-bit)
ODBC 8.0 ANSI (64-bit)
For the NEW LINKED SERVER:
I have tried writing this in "Provider string":
Driver={MySQL ODBC 5.3 ANSI Driver};
DATABASE=myDB;OPTION=134217728;PWD=myPASS;UID=myUSER;SERVER=mySERVER
ODBC:DSN=KARALIGROUP32::Table=myTABLE
I have also tried writing myTABLE in "Catalog".
For the Security tab, I have tried all four options given. (In the last option, I typed the login for MySQL DB and also for SQL Server)
For the Server Options tab, I have tried given RPC and RPC out (both in TRUE or both in FALSE)
I also have to mention that the database SQL Server is not my own one, so I don't have full credentials. This is my user's permissions from SECURITY > LOGINS.
My conclusion: I think it is about MS SQL SERVER MANAGEMENT STUDIO configuration or my permissions as the user.
Thanks for your help!
Update:
I have followed the advise given by TallTed, it didn't work as yet.
In the Security and Server Options tabs, I have left them as shown in the previous screenshots.
I have also tried all the ODBC connections shown in the screenshot.
Any other ideas? Thanks for your help!
First off -- the error you've shown has nothing to do with your SQL Server user permissions.
Next -- it's important to remember that Microsoft SQL Server isn't really an ODBC client application. It is an OLE DB and an ADO.NET client application.
Also note -- 64-bit SQL Server requires a 64-bit ODBC driver; 32-bit SQL Server requires a 32-bit ODBC driver. There are some extra gotchas with 64-bit SQL Server, as described in this article on my employer's site.
If your data is strictly 8-bit "narrow" codepages, then you do not need a Unicode driver, and will probably find it easier to work with the ANSI driver. That said, given that you have ODBC 5.3 Unicode (32-bit) working with Access, I would think you'll have success using that or ODBC 5.3 Unicode (64-bit) with SQL Server.
Now -- a possible step toward success.
In your first screenshot, Product Name must be MSDASQL. You will need no Provider String, because this string comes from your ODBC DSN.
I solved it!
I was using a client computer. I installed the driver in the server and then followed this post: https://www.mssqltips.com/sqlservertip/4570/access-mysql-data-from-sql-server-via-a-linked-server/
Thanks and I hope it would help someone!

mySQL ODBC 5.1 issue: Data source name not found and no default driver specified

I have searched this for several days now (including trying the solution from one link from this site) and I still cannot get this to work...
Problem: I converted an old Visual Studio 2005 project to 2010 on a Windows 7, 64 bit box. Everything works fine, including my ODBC connection to an Oracle database...however, I cannot connect to a mySQL database like I could with VS 2005 on a WinXP 32 bit box.
What I've tried: Uninstalling the 64 bit ODBC driver for MySQL with a 32 bit driver. I added this to my System DSN and the test connection works fine (from odbcad32.exe). All other instances of this driver are removed from the User DSN from both odbcad32 and the 64 bit odbc client. I cannot continue my project without accessing this database. I have tried everything from every website thread, and I still cannot find a solution.
I get this error:
The thread '' (0x1648) has exited with code 0 (0x0).
A first chance exception of type 'System.Data.Odbc.OdbcException' occurred in System.Data.dll
An ODBC exception occurred: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
A first chance exception of type 'System.NullReferenceException' occurred in App_Web_uoi23wal.dll
This is the connection string I am using:
mySqlConnectionString = "Driver={MySQL ODBC 5.1 Driver};Server=xx.xxx.xx.xx;Port=3306;Database=xxxx;User=xxxx;Password=xxxx;";
Can anyone please help me with this? I am at my wit's end! ;)
Thanks!
Couldn't find anyone else who has solved this, but I tried this and both worked for me. Original post is old but if anyone else reads this, possible solution for you.
"Driver={MySQL ODBC 5.2 ANSI Driver}; Server=localhost; Database=***; User=****; Password=****; Option=3;"
"Driver={MySQL ODBC 5.2 Unicode Driver}; Server=localhost; Database=***; User=****; Password=****; Option=3;"
Seems like you must actually specify the 'ANSI' or 'UNICODE' string instead of the 'w' or 'a' as has been suggested on other forums and threads. I presume its no coincidence that it is specified exactly like that in the ODBC Data Source Administrator menu (Control Panel -> System -> Administrative Tools -> Data Sources (ODBC) -> Drivers)
This worked for me on MySQL 5.1
Data Sources (ODBC):
- User DSN : delete the specified User DSN
- System DSN : create a new System DSN
Make sure you have only System DNS not both..

MySQL ODBC Issue: Data source name not found and no default driver specified

I'm currently trying to run a classic ASP application which I've been given source code for. I want to set up on my 64bit Windows 7 dev machine and am having trouble with an ODBC based data connection to a MySQL instance.
I'm seeing the error:
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Driver Manager] Data source name not found
and no default driver specified
/includes/<File Name>.asp, line 100
What I've tried:
The connection is DSN-less.
The application is running under IIS app pool with local system permissions. w3wp.exe can be seen running under NT AUTHORITY/SYSTEM in process monitor.
The application is running under IIS app pool with 32 bit applications allowed to run.
Have tried with Connector/ODBC 5.1.10 64 bit version only installed from http://dev.mysql.com (At this point no driver was listed under C:\Windows\SysWOW64\odbcad32.exe but was under C:\Windows\system32\odbcad32.exe)
Have tried with Connector/ODBC 5.1.10 32 bit version only installed from http://dev.mysql.com (At this point no driver was listed under C:\Windows\system32\odbcad32.exe but was under C:\Windows\SysWOW64\odbcad32.exe)
Have tried with Connector/ODBC 5.1.10 32 bit and 64 bit versions installed.
Verified driver name is not misspelled. Along with other checks from here http://support.microsoft.com/kb/306345.
Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=DBName;User=root;Password=Password;Option=3
Additional Information:
I'm monitoring in process monitor, and the two results are:
PATH NOT FOUND (Looking for .asp/web.config which seems odd.
BUFFER OVERFLOW
Both entries show:
User: NT AUTHORITY\SYSTEM
Process:
C:\Windows\SysWOW64\inetsrv\w3wp.exe
C:\Windows\SysWOW64\odbcint.dll
I'm stumped can any one make a suggestion on how I get this running in the context I have described?
Solved the problem now. Recording here in case this of use to others.
The issue was much simpler than it first appeared. The problem was that the application used a mixture of named and unnamed datasources (DSN / DSN-Less).
It was not apparent to me that any named connections were used until I set up the application for debugging in Visual studio. Here is a rough guide to debugging the application in visual studio (Except I used HTTP based website, rather than file system):
http://www.codeproject.com/Articles/28792/Debugging-Classic-ASP-VBScript-in-Visual-Studio-20
Following creating the required DSN, there were some further exceptions being thrown regarding default values in database columns. This was due to a MySQL setting that can be changed in the my.ini file.
http://bugs.mysql.com/bug.php?id=14306
C:\Program Files (x86)\MySQL\MySQL Server 5.5\my.ini
# Set the SQL mode to strict
# sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
sql-mode=""
I found this to work from Windows to MySQL as a DSN-less connection. The trick was to ELIMINATE the port spec at the end of the server address.
"DRIVER={MySQL ODBC 5.3 UNICODE Driver}; Server=**;Database=**;User=**;Password=**; OPTION=3"
Note: Server string is the internet address of the server, BUT NO PORT
SPECIFIED - ie, NO ":3306" on the end