主端查看表为空
mysql>use darren;
Database changed
mysql>show tables;
Empty set (0.00sec)
从端也一样
mysql>use darren;
Database changed
mysql>show tables;
Empty set (0.00sec)
主端建表
mysql> create table test (id int);
Query OK,0 rows affected (0.01sec)
mysql>show tables;+------------------+
| Tables_in_darren |
+------------------+
| test |
+------------------+
1 row in set (0.00sec)
从端查看
mysql>show tables;+------------------+
| Tables_in_darren |
+------------------+
| test |
+------------------+主端插入数据:
mysql> insert into test values (1);
Query OK,1 row affected (0.00sec)
mysql> select *from test;+------+
| id |
+------+
| 1 |
+------+从端:
mysql> select *from test;+------+
| id |
+------+
| 1 |
+------+继续插入数据:
mysql> insert into test values (2);
Query OK,1 row affected (0.00sec)
mysql> insert into test values (2);
Query OK,1 row affected (0.00sec)
mysql> insert into test values (3);
Query OK,1 row affected (0.00sec)
mysql>show master status;+-------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| master-bin.000001 | 1524 | | | |
+-------------------+----------+--------------+------------------+-------------------+从端
mysql> select *from test;+------+
| id |
+------+
| 1 |
| 2 |
| 2 |
| 3 |
+------+
4 rows in set (0.00sec)
mysql>show slave status\G;*************************** 1. row ***************************Slave_IO_State: Waitingformaster to send event
Master_Host:192.168.132.121Master_User: replication
Master_Port:3306Connect_Retry:60Master_Log_File: master-bin.000001Read_Master_Log_Pos:1524Relay_Log_File: relay-log.000003Relay_Log_Pos:1691Relay_Master_Log_File: master-bin.000001Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno:0Last_Error:
Skip_Counter:0Exec_Master_Log_Pos:1524Relay_Log_Space:2059Until_Condition: None
Until_Log_File:
Until_Log_Pos:0Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master:0Master_SSL_Verify_Server_Cert: No
Last_IO_Errno:0Last_IO_Error:
Last_SQL_Errno:0Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id:1Master_UUID: 77278e78-9da8-11e9-bc6c-000c2991dd19
Master_Info_File:/data/mysql/master.infoSQL_Delay:0SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waitingfor moreupdates
Master_Retry_Count:86400Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position:0Replicate_Rewrite_DB:
Channel_Name:
Master_TLS_Version:
主端删除表
mysql>delete from test;
Query OK,4 rows affected (0.01sec)
mysql> select *from test;
Empty set (0.00sec)
从端:
mysql> select *from test;
Empty set (0.00sec)
主端删除库
mysql>drop database darren;
Query OK,1 row affected (0.01sec)
mysql>show databases;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+从端:
mysql>show databases;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+