MySQL – run SELECT statement on another server without defining the table structure

linked-serverMySQL

In MySQL I can query information on another server using federated tables, as long as I've defined the same table structure locally.

In MS SQL Server, however, I can run any SQL statement against a linked server. Is it possible to do the same thing in MySQL?

Best Answer

How is a "linked server" connection different than any other connection defined by a MySQL client?

In MS SQL Server, however, I can run any SQL statement against a linked server. Is it possible to do the same thing in MySQL?

Maybe I'm missing something but yes, just setup a connection.

mysql -u <user> -p <password> -D <database> -H 127.0.0.1

import MySQLdb
db = MySQLdb.connect(host="localhost", user="<user>", passwd="<password>", db="<database>")

You could go so far as setting up a reverse tunnel with SSH.

mysql -u <user> -p <password> -D <database> -H 127.0.0.1 -P 33061

Other than that, FEDERATED tables are the closet thing.

I must be missing something.