You are on page 1of 2

EJEMPLO DE UNA BASE DE DATOS FEDERADA DE

MANERA LOCAL
------EN EL SERVIDOR REMOTO --------
C:\Users\JoeHero>mysql -u root -p
Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 2
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show engines;


+--------------------+---------+----------------------------------------------------
------------+--------------+------+------------+
| Engine | Support | Comment
| Transactions | XA | Savepoints |
+--------------------+---------+----------------------------------------------------
------------+--------------+------+------------+
| InnoDB | DEFAULT | Supports transactions, row-level locking, and
foreign keys | YES | YES | YES |
| MRG_MYISAM | YES | Collection of identical MyISAM tables
| NO | NO | NO |
| MEMORY | YES | Hash based, stored in memory, useful for temporary
tables | NO | NO | NO |
| BLACKHOLE | YES | /dev/null storage engine (anything you write to it
disappears) | NO | NO | NO |
| MyISAM | YES | MyISAM storage engine
| NO | NO | NO |
| CSV | YES | CSV storage engine
| NO | NO | NO |
| ARCHIVE | YES | Archive storage engine
| NO | NO | NO |
| PERFORMANCE_SCHEMA | YES | Performance Schema
| NO | NO | NO |
| FEDERATED | YES | Federated MySQL storage engine
| NO | NO | NO |
+--------------------+---------+----------------------------------------------------
------------+--------------+------+------------+
9 rows in set (0.00 sec)

ACTIVAR EL FEDERATED, SIGUIENDO LOS PASOS EN LA PRACTICA

mysql> create database bibliotecas;


Query OK, 1 row affected (0.01 sec)

mysql> use bibliotecas


Database changed
mysql> Create table alumnos(matricula char(8) primary key, nombre varchar(20),
apellidos varchar(40), carrera varchar(20), semestre varchar(15)) engine=innodb;
Query OK, 0 rows affected (0.09 sec)

mysql> Grant select, insert, update, delete on bibliotecas.alumnos to


server01@localhost identified by "servidor01";
Query OK, 0 rows affected, 1 warning (0.00 sec)

----- Esto es si usted no cuenta con otra pc, usaremos el


servidor remoto y servidor 01 de manera local -----
ABRA OTRA TERMINAL O VENTANA DE CMD E INICIE SESION COMO
ROOT
C:\Users\JoeHero>mysql -u root -p
Enter password:

Welcome to the MySQL monitor. Commands end with ; or \g.


Your MySQL connection id is 2
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its


affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database servidor01;


Query OK, 1 row affected (0.00 sec)

mysql> use servidor01;


Database changed

mysql> create table alumnos(matricula char(8) primary key, nombre varchar(20),


apellidos varchar(40), carrera varchar(20), semestre varchar(15)) engine=federated
connection='mysql://server01:servidor01@localhost:3306/bibliotecas/alumnos';
Query OK, 0 rows affected (0.01 sec)

mysql> select * from alumnos;


+-----------+--------+-----------+----------+----------+
| matricula | nombre | apellidos | carrera | semestre |
+-----------+--------+-----------+----------+----------+
| 1 | jose | hernandez | sistemas | sexto |
+-----------+--------+-----------+----------+----------+
1 row in set (2.03 sec)

NOTA ESTE SELECT, MUESTRA EL INSERT QUE SE HIZO EN LA OTRA VENTANA (SERVIDOR REMOTO,
RECUERDE HACER LOS INSERT, UPDATE, DELETE DE LA PRACTICA)

NOTA: recuerde que la base de datos del servidor remoto se llama bibliotecas, y al
mismo tiempo el que funge como servidor 01, la base de datos se llama servidor01.

You might also like