Database Research & Development

  • Home
  • NoSQL
    • NoSQL
    • Cassandra
  • Databases
    • Database Theory
    • Database Designing
    • SQL Server Coding Standards
    • SQL Server
    • PostgreSQL
    • MySQL
    • Greenplum
    • Linux
  • Interviews
    • SQL Server Interviews
    • MySQL Interviews
    • SQL Puzzles
  • DBA Scripts
    • SQL Server DBA Scripts
    • PostgreSQL DBA Scripts
    • MySQL DBA Scripts
    • Greenplum DBA Scripts
  • Home
  • Blog Archives !
  • (: Laugh@dbrnd :)
  • Contact Me !
sqlserverinterviews
Home 2016 January MySQL: Create FEDERATED Table to SELECT data from another server (Part 3/4)

MySQL: Create FEDERATED Table to SELECT data from another server (Part 3/4)

This article is half-done without your Comment! *** Please share your thoughts via Comment ***

In the previous post, we have seen a basic theory and configuration of FEDERATED table. In this post, I am going to create a FEDERATED table which is used to SELECT data from another MySQL Server.

How to create FEDERATED Tables?

Assume that we have two running servers, either both on the same host or different hosts.

For example:

Server – A108 (Remote MySQL Server)
Server – B108 (Local MySQL Server)

We need to execute the SELECT command from Server B108 and fetching data from Server A108.
Here, Server A108 is a remote server and Server B108 is a local server.

Now create a sample table in Server A108.

1
2
3
4
5
6
CREATE TABLE tbl_RemoteTable
(
ID integer
,Name VARCHAR(255)
)
ENGINE=InnoDB;

Now, create a FEDERATED table in Server B108 to SELECT data from Server A108.
You have to specify FEDERATED engine with remote CONNECTION information.

1
2
3
4
5
6
7
CREATE TABLE tbl_RemoteTable
(
ID integer
,Name VARCHAR(255)
)
ENGINE=FEDERATED
CONNECTION='mysql://root:root@localhost:3306/B108/tbl_RemoteTable';

As you can see, I created FEDERATED table into Local Server B108 using the connection information of Remote Server A108.

You can access this table like any other table, and if any data insert or delete in remote Table, it automatically updates here because this is a virtual table.

Below are different format of connection strings:

1
2
3
CONNECTION='mysql://username:password@hostname:port/database/tablename'
CONNECTION='mysql://username@hostname/database/tablename'
CONNECTION='mysql://username:password@hostname/database/tablename'

Jan 31, 2016Anvesh Patel
MySQL: Configured and Enable FEDERATED engine (Part 2/4)MySQL: The Important Notes and Tips of FEDERATED Storage Engine (Part 4/4)
Comments: 5
  1. julis
    February 3, 2016 at 2:28 am

    Hi, yeah this article is genuinely nice and I have learned lot of
    things from it concerning blogging. thanks.

  2. Vincent
    February 18, 2018 at 1:04 am

    In your example you connect to “localhost”. is that just a bad example? I’m asking because I’m having trouble connecting and I need to make sure I’m passing in the correct values. It actually created the federated table no problem, but I can’t select from it because I get an access denied error.

    • Anvesh Patel
      Anvesh Patel
      February 25, 2018 at 6:24 pm

      Please check server/user permissions…

  3. toni
    September 10, 2019 at 2:39 am

    why is the data in in Server A108 is null?

  4. toni
    September 10, 2019 at 2:41 am

    why is the data in Server A108 is null?

Anvesh Patel
Anvesh Patel

Database Engineer

January 31, 2016 MySQLAnvesh Patel, connection, database, database research and development, dbrnd, FEDERATED Engine, MySQL, MySQL Command, MySQL Database Administrator, MySQL Database Designing, MySQL Database Programming, MySQL Error, MySQL Performance Tunning, MySQL Query, MySQL Tips and Tricks, remote
About Me!

I'm Anvesh Patel, a Database Engineer certified by Oracle and IBM. I'm working as a Database Architect, Database Optimizer, Database Administrator, Database Developer. Providing the best articles and solutions for different problems in the best manner through my blogs is my passion. I have more than six years of experience with various RDBMS products like MSSQL Server, PostgreSQL, MySQL, Greenplum and currently learning and doing research on BIGData and NoSQL technology. -- Hyderabad, India.

About DBRND !

dbrnd

This is a personal blog (www.dbrnd.com).

Any views or opinions represented in this blog are personal and belong solely to the blog owner and do not represent those of people, institutions or organizations that the owner may or may not be associated with in professional or personal capacity, unless explicitly stated.

Feel free to challenge me, disagree with me, or tell me I’m completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or anonymous comments) - so keep it polite.

The content of this website is protected by copyright. No portion of this website may be copied or replicated in any form without the written consent of the website owner.

Recent Comments !
  • Anvesh Patel { Sure will do... } – May 27, 12:43 PM
  • Anvesh Patel { Great... } – May 27, 12:41 PM
  • Anvesh Patel { Great... } – May 27, 12:39 PM
  • Anvesh Patel { Great... } – May 27, 12:36 PM
  • Anvesh Patel { Great... } – May 27, 12:28 PM
  • Anvesh Patel { Great... } – May 27, 12:27 PM
  • Anvesh Patel { Great... } – May 27, 12:16 PM
  • Older »
Follow Me !
  • facebook
  • linkedin
  • twitter
  • youtube
  • google
  • flickr
© 2015 – 2019 All rights reserved. Database Research & Development (dbrnd.com)
Posting....