Linkedserver connection to MySQL database with ODBC driver failed

binrip 0 Reputation points
2024-09-17T05:53:47.2933333+00:00

Hi
I am attempting to use a SQL Server 2014 linked server to connect to a MySQL 8 instance. My single openquery insert statement works fine, but when I try to run multiple insert statements to insert data to multiple tables, I receive a generic error message. Sometimes it works without error during off-peak hours. The error message I receive is:

OLE DB provider "MSDASQL" for linked server "MYSQL-LINKED-SERVER" returned message "[MySQL][ODBC 8.4(w) Driver]Lost connection to MySQL server at 'waiting for initial communication packet', system error: 10060".

This is the insert statement I am using:

INSERT INTO OPENQUERY([MYSQL-LINKED-SERVER],'SELECT  id, name, state_date, created_at, updated_at, created_byFROM Db1.table1') SELECT  id, name, state_date, created_at, updated_at, created_by FROM source a

I have already tried modifying some settings on the Windows server hosting the queries, and I have enabled certain flags on the MySQL side. Can someone please help me pinpoint what could be causing the issue?

Azure Database for MySQL
Azure Database for MySQL
An Azure managed MySQL database service for app development and deployment.
818 questions
SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
13,690 questions
Windows Server
Windows Server
A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.
12,957 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Olaf Helper 44,311 Reputation points
    2024-09-17T06:17:50.8933333+00:00

    Can't connect to MySQL server on 'ip:port' (10060)".

    Are you sure about the used IP port 10060? Default is 3306.

    Can you connect your MySQL Server other tools like Wockbench?

    Can you run a simple SELECT statement against the linked server?


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.