connecting to a MySQL database from MSSQL Management Studio - mysql

Somehow I'm having a lot of trouble establishing an ODBC connection to MySQL from within MSSQL Management Studio. I have 64-bit versions of MSSQL and MySQL ODBC connector installed.
The local MySQL database already has a DSN assigned to it. I've used this DSN with Excel in the past and had no problems.
Now, (in SQL Man. Studio) when I access:
'Tasks' -> 'Import Data' -> '.Net Framework Provider for ODBC'
I get a helpful form asking me to enter all the connection details even though I've already registed the DSN in 'Control Panel\Data Sources'.
So, after a brief 'wait, what?", I enter:
Dsn: My_Dsn
Driver: MySQL ODBC 5.2 ANSI Driver
... and get: ERROR [IM014] [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
#
PS.
I've also tried creating a linked MySQL server in MS Studio like so: http://www.sqlservercentral.com/Forums/Topic340912-146-1.aspx
and get:
'contains no columns that can be selected or the current user
does not have permissions on that object.'
In short: no access to MySQL from within MSSQL Studio whatsoever
Thanks in advance!

Related

SQL Server 2016 Fails Cryptically (Error #7303) on Link to MySQL, But Access 2016 Succeeds with Same System DSN

I am going around in crop circles, trying to set up a linked server (from SQL Server 2016 to MySQL).
Here is the basic procedure that I used: Create a Linked Server to MySQL from SQL Server. Upon clicking OK to create the new linked server, I received the following SSMS 2016 spasm, Error #7303:
The linked server has been created but failed a connection test. Do you want to keep the linked server?
Additional information:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MYSQL".
OLE DB provider "MSDASQL" for linked server "MYSQL" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". (Microsoft SQL Server, Error: 7303)
I tried variations that included a Provider String and Catalog (same error):
I have tried the latest MySQL ODBC ANSI/Unicode drivers (5.03.07.00), set up via System DSNs in both the 32- and 64-bit versions of the ODBC Data Source Administrator.
Now, I suspect that something screwy is going on with MS SQL Server and/or its OLE-DB Provider (MSDASQL), because:
All tests of the System DSNs within the ODBC Data Source
Administrator are successful.
Crippled Access 2016 is able to link (via the aforementioned Unicode System
DSN) to MySQL just fine, with minimal effort, listing all databases
and tables.
What is the magic that SQL Server 2016 needs to make the linked-server dialog not result in the above error?
Two things --
Product Name should be MSDASQL.
Leave Provider String and Catalog blank (these are typically taken care of by your DSN definition).
That should do it...

Create a Linked Server for a MySQL Database in SQL Server 2005

I'm currently trying something I've never done before - I'm trying to access MySQL data in an SQL Server environment. Where I am, we have two servers (the MySQL and MSSQL servers), and each stores different types of data. Recently I've found a need to write queries that include data for both servers. One of the ways I read to do this is adding a "Linked Server" in SQL Server. But try as I might I cannot seem to get a Linked Server added.
I am working on a Windows 7 system, our SQL Server instance is 2005, and the MySQL version is 5.5.31.
What I've done so far is this:
Downloaded and installed the MySQL ODBC drivers
Created a System DSN using that driver for the MySQL database, called "Production". (I also tested the connection from the Data Sources application and it connects just fine).
Checked for the Provider in SQL Server (MSDASQL) to configure options such as "allow nested queries" and "allow 'LIKE' operator"
right click on Linked Servers in Server Objects in SQL Server > "New Linked Server"
From here, I fill out the linked server info like this:
Checked "Other data source" (not SQL Server)
Chose Provider "Microsoft OLE DB Provider for ODBC Drivers"
Product Name: "Production"
Data Source: (the name of the System DSN) Production
Then in the security tab, I chose the "Connections will be made using this security context" and provided my username and login for the MySQL server.
Then this is where I run into an error every time. I always get the following error message:
The linked server has been created but failed a connection test. Do you want to keep the linked server?
ADDITIONAL INFORMATION:
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.Express.ConnectionInfo)
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "FLUX".
OLE DB provider "MSDASQL" for linked server "FLUX" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". (Microsoft SQL Server, Error: 7303)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=09.00.5000&EvtSrc=MSSQLServer&EvtID=7303&LinkId=20476
If you click that link for help, by the way, nothing shows up.
I saw other people suggested trying an older MySQL ODBC driver, adding a System Data Source for the 32bit driver as well as the 64bit driver, and restarting my machine (not the DB server) -- none of these fixed my error.
What I do not understand is why my System DSN seems to work and connect fine, but SQL Server cannot see the Data Source. Does anyone see what I'm missing, or what I might be configuring incorrectly?
EDIT
Clarified that I restarted my local machine, but not the DB server since trying to add the Linked Server.
From everything you've said, you probably have a mismatch between bitnesses of SQL Server 2005 components and the installed ODBC Driver for MySQL.
System DSNs are definitely the way to go.
You probably will need to install both the 32-bit and 64-bit ODBC driver, and configure an identical (same name and everything!) System DSN with each.
I would say you may also want/need to install this patch it was useful for getting XP and 2003 to work properly for ODBC type connections for me.
http://www.microsoft.com/downloads/details.aspx?FamilyID=000364db-5e8b-44a8-b9be-ca44d18b059b&displaylang=en
Is your Database server on the same machine on which you have Sql Server Management Studio Installed? If the SQL Server is on a remote machine then you need to install the ODBC driver on remote Machine and create the DSN there as per link
I was having the same issue but the above link solved my problem.

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

Linked servers - SQL2008 to MySql - error: 7303 - Data source

Problem:
I use SQL Server 2008.
We have here a linked server, linking to a MySql Database.
But since today, when I click "test connection", it shows me this error:
( I can't post images yet):
The test connection to the linked server failed.
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "MANTIS".
OLE DB provider "MSDASQL" for linked server "MANTIS" returned message "[Microsoft][ODBC Driver
Manager] Data source name not found and no default driver specified". (Microsoft SQL Server,
Error: 7303)
What should I do?
It was working yesterday. I thought about "data sources ( ODBC)". Yes, There is no DataSources for MySql ( it doesn't even show me the option to add a mySql odbc when I click ADD), but it was working yesterday !!
I didn't find a reasonable solution from any post.
answer, taken from the question
Restart server + Install MYSQL ODBC DRIVER 51 ( MySql connector )
Start - control panel > Administrative Tools > Data Sources (ODBC) > System DSN > ADD
MySql ODBC 501 Driver

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).