I have created a linked server using ODBC driver with following provider string
DRIVER={MySQL ODBC 5.1 Driver};SERVER=HOST;USER=uid;PASSWORD=pw;OPTION=3
My linked server is named MYSQL. If i do Select and UPDATE in that way it works right
SELECT * FROM OPENQUERY(MYSQL,'SELECT * FROM DatabaseName.Table')
UPDATE OPENQUERY(MYSQL, 'SELECT * FROM DatabaseName.Table where test=0') SET test=1
when i try to perform an insert with following syntax
INSERT OPENQUERY(MYSQL,'SELECT Column1, Column2, Column3 from DatabaseName.Table WHERE 1=0') VALUES (10,20,30)
i have this following error
The OLE DB provider "MSDASQL" for linked server "MYSQL" could not INSERT INTO table "[MSDASQL]". Commands out of sync; you can't run this command now.
I think you've got the same problem as this thread on another forum. From the answer that seems to have solved the problem for people there, it looks like your missing the database name from your provider string. Try adding DATABASE=mydb; to your provider string.
Here is the original answer:
Apparently if you try to create the linked server using studio and the
various menus, a small detail is not saved in the connection string,
which is the database!
EXEC master.dbo.sp_addlinkedserver #server='MYSQL', #srvproduct='MySQL',
#provider='MSDASQL', #provstr='DRIVER={MySQL ODBC 5.1
Driver};SERVER=HOST;Port=3306;USER=uid;PASSWORD=pw;OPTION=3;DATABASE=mydb;
the bug in the odbc driver seems to affect only the insert statement
and has been around since 2008... i would have hoped that mysql fixed
it by now...
after you create the linked server using the procedure as above, the
insert works as well as all the rest!
I just experienced the same problem and managed to solve it by deactivating Force use of forward-only cursor and Don't cache results for forward-only cursor for my ODBC connection.
I don't know for sure if both options need to be disabled. I got the hint from here
I linked SQL Server 2012 to MySQL v5.1 via MySQL ODBC/Connector v5.1.11, 64-bit. My link data source is configured to use a system ODBC DSN which already had the MySQL database specified (this is in relation to the previous answers) and yet I still got the error before deactivating those cursors options (by default they are not enabled for new data sources, I was the one who enabled them at some point).
Related
I've built a pretty basic database using MySQL Workbench - and I've uploaded a bunch of data. Now I am trying to pull data from my database into MS Excel using an ODBC connection via Excel's Get Data. However, after setting up the ODBC connection, I'm getting the following error for ALL my data fields/columns:
DataSource.Error: ODBC: ERROR [42000] [MySQL][ODBC 8.0(w) Driver][mysqld-8.0.26]You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near '.columns_priv' at line 8 Details:
DataSourceKind=Odbc
DataSourcePath=dsn=MySQL Local
OdbcErrors=[Table]
I've searched all over for ideas - I've even tried adding text: SET sql_mode='ANSI_QUOTES' into the Initial Statement field in the Details option in the ODBC connector, as I thought it could be quotes related?
My versions:
MySQL Workbench 8.0.26,
MySQL Connector/ODBC 8.0.26,
MS Excel 2019
Can anyone see where I'm going wrong, or how I can fix this?
Any help would be most appreciated. Thanks,
Stevie
i tested it with my mysql 8.0.26
i used
MySQL ODBC UNICODE driver
My Server is configured to run in legacy mode on local host, but when youz can conect via Workbench, you can use tcpip and localhost
The steps are
Connecting Excel to MySQL with Data Connection Wizard (Legacy Wizard)
Start a new worksheet
Go to the Data tab.
Click From Other Sources, and then click From Data Connection Wizard.
In the opened dialog, you select ODBC DSN and click Next to continue.
Now select a data source you want to connect to, and click Next.
To connect to the table containing the wanted data, select its name and click Next to enter and save information about your new file or click Finish.
In the Import data dialog, you can select the way your data will be viewed in Excel and the place where to put it in the worksheet, and click OK.
The selected data are displayed in the prior empty Excel worksheet.
Good morning.
Have the same issue since updating mysql and mysql odbc to 8.0.26.
mysqld on centos and odbc on windows 10.
Working fine on 8.0.25
Thinking on rollback.
You all have a nice day
I got the same problem. I changed ODBC 8.0 Unicode Driver to 5.3 version. Problem solved.
Same issue.
According to the error log, the odbc adds a nonsense pair of backquotes between the database name and table name in the "select ... from ..." sql.
Downgrade my mysql odbc version to 8.0.25.
Problem solved.
I have a SSIS package which is used to export data from a MySQL database to a SQL database.
For some reason, I can only read data using the ODBC Source item but I cannot preview the table, also, while doing some other tests I found out I can't insert data with the ODBC Destination item either.
Whenever I try I get this error:
ERROR [42000] [MySQL][ODBC 8.0(w) Driver][mysqld-5.7.23]You have an
error in your SQL syntax; check the manual that corresponds to your
MySQL server version for the right syntax to use near "TABLENAME"
at line 1 (myodbc8w.dll).
I'm using MySQL 5.7.23 and MySQL Connector/ODBC 8.0. I have tried switching between ANSI and Unicode connectors; downgrading the connectors version (tried it with 5.3, 5.2 and 5.1); changing database, table and column codification; changing the data access mode in the ODBC Source item (was using "Table Name" by default); remaking the task. Everything results in the same error, even on different computers and databases.
EDIT:
Using #Hadi second workaround lead to some interesting results (the first one didn't work for me).
Using either the ADO.NET or ODBC connector, the provided query resulted in an error.
Error Code: 1231. Variable 'sql_mode' can't be set to the value of 'NO_AUTO_CREATE_USER'
After modifying the query to
set sql_mode = 'STRICT_TRANS_TABLES, NO_ENGINE_SUBSTITUTION, ANSI_QUOTES'
the error changed to a warning.
set sql_mode='STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES' 0 row(s) affected, 1 warning(s): 3135 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
Still, it worked partially. Any quotations, accents, or any other symbol surrounding any selected table name had to be removed. That made it work fine when inserting data, but when retrieving data it had to be done either from a SQL command or by creating 2 different connections.
While searching for the issue i found some helpful links that mentioned some workaround:
(1) Connecting to MySQL issue
Connecting to MySQL from SSIS
In this link the author mentioned 2 methods to connect to MySQL (using ODBC and ADO.net). He mentioned that while trying to retrieve tables using ODBC he received the same error that you have listed in the question, and he mentioned the solution as below:
Switching to use a SQL query instead, and that worked just fine. I was able to pull back both the correct metadata, with one small problem - the varchar(50) columns came back with a length of 51. This resulted in some warnings, but the package ran correctly.
(2) Writing to MySQL issue
Writing to a MySQL database from SSIS
In this article the author mentioned how to write to a MySQL destination using ADO.Net destination, he mentioned the solution below:
For the ADO.NET Destination to work properly, the MySQL database needs to have the ANSI_QUOTES SQL_MODE option enabled. This option can be enabled globally, or for a particular session. To enable it for a single session:
Create an ADO.NET Connection Manager which uses the ODBC driver
Set the connection manager’s RetainSameConnection property to True
Add an Execute SQL Task before your data flow to set the SQL_MODE – Ex. set sql_mode='STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,ANSI_QUOTES'
Make sure that your Execute SQL Task and your ADO.NET Destination are using the same connection manager.
Other similar links
SSIS problems with MySQL Connector/ODBC 5.3.8
SSIS and MySQL - Table Name Delimiter Issue
I just set up CF10, win2008, IIS 7.5 with mysql 5.6. But we are getting this error:
Error Executing Database Query.
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OPTION SQL_SELECT_LIMIT=DEFAULT
This error is removed when I explicitly set "LIMIT" to the queries.
(Update from comments)
Here is an example:
<cfquery name="dds" datasource ="#Request.Datasource#">
SELECT *
FROM tblaccounts
LIMIT 100
</cfquery>
As far as my research shows, it's an incompatibility with the new version of mysql 5.6.
Borrowing some from the answers above with more detail:
We were having the same problem and it was fixed by updating the JDBC file. Since ColdFusion 10 only supports MySQL 5.0 and 5.1, you need to update the Connector as mentioned above.
To update the JDBC Connector on your Windows machine,
Obtain the .zip connector from the link provided above
Open the zip archive and locate the mysql-connector-java-5.1.23-bin.jar
Copy this .jar file to C:\ColdFusion10\cfusion\lib\
Open Services (Start > Control Panel [Optional] > Administrative Tools > Services)
Stop/Start the "ColdFusion 10 Application Server" service
To verify the new .jar is has been recognized by ColdFusion, login to your ColdFusion Administrator, click on "Settings Summary" under "Server Settings". Search for "mysql". You should see the .jar file listed under the "CF Server Java Class Path" section. There is no need to re-setup datasources. These changes should automatically apply.
From what I understand another option should be to update the JDBC driver to the latest MySQL JDBC Driver. You can find instructions on using the latest JDBC driver here: (though the instructions may be a bit old, it should still work pretty much the same way).
FYI ColdFusion 10 only supports MySQL 5.0 and 5.1.
Thanks much Clark - we just had the same issue with CF9
This actually applies to CF9 as well.
Step 3 is then: Copy this .jar file to C:\ColdFusion9\lib\
Step3a Rename the old driver mysql-connector-java-commercial-5.1.11-bin.jar.old
Otherwise drivers may conflict. (happened before)
After the update the bug seemed to be gone. :)
MySQL 5.6 is now supported in ColdFusion 10 update 11, details here: http://helpx.adobe.com/coldfusion/kb/coldfusion-10-update-11.html
MySQL deprecated SET OPTION a long time ago, see the docs, and it was removed in 5.6
You need to use SET without the OPTION statement,
SET SQL_SELECT_LIMIT = 100;
Will do what you want.
Be aware that this sets the default for a single connection. To ensure that your subsequent query uses the same connection wrap them in a <cftransaction>
<cftransaction>
<cfquery name="tmp" datasource ="#Request.Datasource#">
SET SQL_SELECT_LIMIT = 100;
</cfquery>
<cfquery name="dds" datasource ="#Request.Datasource#">
SELECT *
FROM tblaccounts;
</cfquery>
</cftransaction>
An alternative is to enable multiple queries for the datasource, but this is not recommended for security reasons.
Long time lurker, first time poster; hoping anyone can help me out.
Im using MySQL Workbench 5.2.41 to migrate a database from SQL Server to MySQL 5.0.8
The entire process goes smoothly: both SQL and MySQL connection Tests are good, the skemea and table create as expected, everything checks out until the 'Bulk Data Transfer' step. At that point I receive this error:
...
Migrating data...
wbcopytables.exe --odbc-source=DSN=SQL Server 11;DATABASE=;UID=sa --target=root#127.0.0.1:3306 --progress --passwords-from-stdin --thread-count=1 --table [GSAClosers_v2] [dbo].[AccountBase] `dbo` `AccountBase`
`dbo`.`AccountBase`:Copying 84 columns of 169530 rows from table [GSAClosers_v2].[dbo].[AccountBase]
ERROR: `dbo`.`AccountBase`:SQLGetData: HY009:10:[Microsoft][ODBC Driver Manager] Invalid argument value `dbo`.`AccountBase`:
Finished copying 0 rows in 0m00s
Copy helper has finished
...
For connectors I'm using Microsoft SQL Server / ODBC Data Source / DSN: SQL Server and for MySQL the IP and port(3306).
SQL Server 2012 Management Studio connects and all operations work as expected.
O, side not: both are on the same localhost machine.
If anyone can shed some light on this I would be forever indebted. Thanks in advance
From here:
[Microsoft][ODBC Driver Manager] Invalid argument value.
Regarding to the error message and code you provided, which seems is
database is invalid or cannot be accessed. That means either the
database does not exist or the user does not have permission to access
the database.
It turns out you need specify the instance after the server name, so
in the server name in the dialog box for creating the ODBC Data
Source, you must enter it as either: MyServer\SQLEXPRESS or
.\SQLEXPRESS
I think you may have a problem connecting to your database from wbcopytables.exe. Keep in mind that this is a separate tool so the fact that you can connect from the rest of the Migration Wizard doesn't imply that you will connect in wbcopytables.exe.
The thing that worries me the most is that your DSN has whitespace characters. This might be interpreted by the Windows terminal as independent command line parameters. One thing you can do is to edit your DSN name removing the whitespaces and try again.
You may also want to connect without a DSN by putting all your connection parameters explicitely as explained in my blog post: How-To: Guide to Database Migration from Microsoft SQL Server using MySQL Workbench.
And, by the way, since MySQL Workbench 5.2.42 is out you should go and get it. The Migration Wizard is pretty new so important bug fixes are likely launched in each recent Workbench release.
In either case I think you should file a bug with your issues with a detailed explanation about how to reproduce it, possible solutions, etc.
Hope this helps.
Ok, got it figured out: un-install java. install java 1.6, use MySQL Migration Tool. change all data types to varchar, ints and bits. run migrations....eat data.
I am working with SSIS and trying to import data from MySql to SQL Server. I am having issues trying to convert mySql datetimes to SQL Server Datetimes. Any suggestions?
Can you provide an example of the error or problem? I found some values in MySQL were out of range to SQL Server. In these instances, I used a NULLIF on the MySQL side to remove the bad values first. Rafal Ziolkowski's solution of converting to strings could work as well, but I personally would prefer to push the conversion off to the MySQL query if it is only impacting data columns.
Try convert date to string and then to datetime again.
What is the issue? Which SSIS data type are you using? DT-DBTIMESTAMP should work for both.
this took me few days to figure out...so I thought I would share my notes
How to connect and load data from MySQL to SQL Server
Download the 32 bit ODBC driver.
go to the MySQL website and download: “mysql-connector-odbc-5.2.4-ansi-win32.msi”
NOTE: Do not use the 64 bit driver on BIDS 2008. BIDS 2008 is 32 bit. You will get a mismatch error when creating SSIS’s connection manager: “The specified DSN contains an architecture mismatch between the Driver and Application”
Create a User DSN
You need to open the using windows 32 ODBC admin tool. DO NOT open the regular ODBC admin, in control panel. Open the ODBC admin located here: c:\Windows\SysWOW64\odbcad32.exe. If you use the default ODBC admin…it will not work. Additionally you must create a “User DSN” - NOT a System DSN. Otherwise it will not show up in SSIS
NOTE: the screens look the same so you will have no way of knowing whether you are in 32 BIT ODBC Admin tool or not.
Create a new SSIS package and create an ADO.NET connection manager:
Change the Source ADO.NET properties.
You will get validation errors and your package will not run. You need to change the “ValidateExternalMetadata” to FALSE (in the “Advanced Editor” dialog box) of the ADO.NET source It will also give you metadata error…that’s ok…just click ok. It will still pull the metadata (column names/data types). You cannot select the tables as you would in SQL server. You need to type the SQL select statement.
Run the package and should run and load normally.