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

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!

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

microsoft odbc driver manager data source name not found and no default driver specified

I am trying to run a Classic ASP application on Windows 8.1. It keeps on failing with error: data source name not found and no default driver specified
I am using an Access database. I have the same problem using a MySQL database. I tried with both 32 bit and 64 bit MySQL drivers -- first installing one then uninstalling and then installing the other.
driver={MySQL ODBC 5.3 Driver};option=3;server=localhost;user=root;password=;DATABASE=test;
I'm using these MySQL ODBC drivers:
mysql connector 5.3.4 - win32
mysql connector odbc 5.3.2 - winx64
Access can't be accessed through the MySQL drivers (they're for MySQL not Ms Access), what you need is the Microsoft OLEDB database connections.
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\myFolder\myAccessFile.accdb;
Jet OLEDB:Database Password=MyDbPassword;
Source; https://www.connectionstrings.com/access/
Also for MySQL, if you're running a 32bit MySQL server on a 64bit machine the standard ODBC management tool won't work since it's the 64bit version by default.
You'd need to install in on the 32bit ODBC manager here c:\Windows\SysWOW64\odbcad32.exe
Once that's done you'd need the following connection string to work with a 32bit DB on a 64bit machine. Provider=MSDASQL;Driver={MySQL ODBC 5.2 ANSI Driver};Server=localhost;
Database=myDataBase;User=myUsername;Password=myPassword;Option=3;
Source; https://www.connectionstrings.com/mysql-connector-odbc-5-2/

pyodbc + MySQL + Windows: Data source name not found and no default driver specified

I am trying to connect to MySQL 5.6 on a Windows Server 2008 R2 localhost with pyodbc. I used the full installation for the MySQL instance on the localhost, including the ODBC connector. I have it connecting to a remote SQL Server instance beautifully, but for the life of me I can't get it to connect to the local MySQL instance. I am using this guide from connectionstrings.com as reference.
Here's some code:
import pyodbc
def create_mssql_conn():
return pyodbc.connect(r'Driver={SQL Server};Server=MSSQLSRV;Database=ecomm;Trusted_Connection=yes;')
def create_mysql_conn():
return pyodbc.connect(r'Provider=MSDASQL;Driver={MySQL ODBC 5.6 UNICODE Driver};Server=127.0.0.1;Database=ecomm;User=root;Password=myP#$$w0rd;Option=3;')
# conn = create_mssql_conn() # This one works
conn = create_mysql_conn() # This one breaks
cursor = conn.cursor()
cursor.execute('SELECT * FROM inventory')
while 1:
row = cursor.fetchone()
if not row:
break
print row
Here is the error:
pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')
I tried everything from adding Provider=MSDASQL; to changing ANSI to UNICODE in the connection string. Any suggestions?
I was having a similar issue. I am using windows 8, and mysql.
The way I solved the problem was by going into my
control panel>Systems and Security>Administrative Tools.>ODBC Data Sources
Either the 32 bit or 64 bit version depending on your computer.
Then you click on the System DNS file. If you do not see any MySQL driver you have to click ADD. It brings up a list, from that list select the MySQL driver.
For me it was MySQL ODBC 5.3 ANSI(they have a unicode driver also). Click finish. Once you do that then you have to change your connection line in your code to the corresponding Driver that you just filled out.
Ex:
def create_mysql_conn():
return pyodbc.connect(r'Driver={MySQL ODBC 5.3 ANSI Driver};Server=MSSQLSRV;Database=ecomm;Trusted_Connection=yes;')
This should work, or at least it solved my connection issue because I was getting all sorts of different errors with everything I tried. This was what solved the issue for me.
In Win64 there are two ODBC environments: 32 and 64 bit and you can work with Python 32 bit or Python 64 bit. Check what version of Python you use and then use proper version of odbcad32.exe (32 bit version is located in the SysWoW64 directory) to create SystemDSN. With SystemDSN you can check if you can connect to the database. Then try to connect to DB from Python code.
You can list ODBC datasources available to pyodbc via my code recipe: https://code.activestate.com/recipes/578815-printing-list-of-odbc-data-sources-with-pyodbc-mod/
Head to Administrative Tools and the ODBC Data Sources. You should click on the DNS file. Most likely you'd see Microsoft Access and excel as the only data sources available, so you need to add your SQL Server. Mine was SQL Server 2008 R2, and so far, it has worked.
For the error mentioned
"pyodbc.Error: ('IM002', '[IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified (0) (SQLDriverConnect)')"
I installed the 'Microsoft Access Database Engine 2010 Redistributable 64-bit' as I have 64-bit system and then added the DSN in the directory of MS Access database and it's working now.
Here is the link of the video for how to create DSN and connect to python.
https://www.youtube.com/watch?v=zw9P2wSnoIo

Which connection string for MySql ODBC connector 5.2.6?

it seems i can't make work a connection to MySql using ODBC connector 5.2.6.
In a 64 bit environment, in a VBA excel application, i use this string, but it not work:
"Driver={MySQL ODBC 5.2
Driver}; Server=myserver;Database=mydb;User=readonly;Password=mypass;Option=3"
I have also used
Driver={MySQL ODBC 5.2w Driver}
and
Driver={MySQL ODBC 5.2a Driver}
But the error is: ODBC driver unknow.
Can someone help me ?
Ps: it works with a DSN setted, but i would like to use a connection string so i don't go to each user computer and set a DSN.
Thanks
Quick Answer
Make sure you have installed the correct ODBC version (64-bit or 32-bit), matching the software.
Try the following:
Replace Driver={MySQL ODBC 5.2w Driver} with Driver={MySQL ODBC 5.2 Unicode Driver}
Replace Driver={MySQL ODBC 5.2a Driver} with Driver={MySQL ODBC 5.2 ANSI Driver}
Long Answer
The Driver={driver name} part of an ODBC connection string is the driver name that is listed in the Data Sources (ODBC) dialog.
Because you are running in a 64-bit environment, what you do next depends on whether you are running Excel (or whatever the software, web app etc.) as 32-bit or 64-bit, and therefore make sure you've installed the appropriate MySQL ODBC driver version. This is probably the most common problem people run into with ODBC drivers on 64-bit systems.
For those running web servers and trying to get 32-bit ODBC drivers to work in their 32-bit web app, make sure you enable 32-bit applications on the application pool. Here is a forum post describing how to do this: http://forums.iis.net/post/2023543.aspx
64-bit
If the software is 64-bit then open the Run dialog box, and run %windir%\System32\odbcad32.exe.
Click the Drivers tab, and find the MySQL ODBC driver listed, remember the name in the Name column, and use that in the connection string.
For 5.2.6 this will most likely be: MySQL ODBC 5.2 Unicode Driver
Where the driver name you tried before was 5.2w use the Unicode driver, where it was 5.2a use the ANSI driver.
32-bit
If the software is 32-bit then in the Run dialog box run %windir%\SysWOW64\odbcad32.exe to open the 32-bit Data Sources dialog, and then do the same as above.
On 64-bit machines using the 32-bit driver, it is recommended to start the connection string with Provider=MSDASQL;
I had a similar problem with Access 2010/2013 and windows 7. I assumed that I needed the 64 bit driver for a 64 bit environment and could not make a connection whatever I did. I finally downloaded and installed the 32bit version and am now able to connect to MySQL database on a remote server. As Excel is an also Office product I expect the problem/solution is the same.

Mysql table on Excel sheet?

I am using Windows7 and Microsoft office 2010 and mysql5. I want to connect Microsoft excel with my database mysql. I have installed all the drivers. I have created a data source as well. I am going step-by-step to connect, but at the end when i click on test connections, I receive this error message
Test connection failed because of error in intializing provider unspecified error.
You probably are not using the right ODBC driver.
Please check if you downloaded the one that matches your MySQL database. (not only version number, but especially if it is a 32-bit server or a 64-bit server).