[root@db02 data]# mysql -S /data/3306/mysql.sock 查看变量: mysql> show variables like 'log_bin%'; +---------------------------------+----------------------------+ | Variable_name | Value | +---------------------------------+----------------------------+ | log_bin | ON | | log_bin_basename | /data/3306/mysql-bin | | log_bin_index | /data/3306/mysql-bin.index | | log_bin_trust_function_creators | OFF | | log_bin_use_v1_row_events | OFF | +---------------------------------+----------------------------+ 5 rows in set (0.00 sec) 2、建账号授权【主库】 grant replication slave on *.* to 'rep'@'172.16.1.%' identified by 'oldboy123'; flush privileges; 3、锁表导出数据 mysql> flush table with read lock; Query OK, 0 rows affected (0.00 sec) 查看位置: mysql> show master status; +-------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-------------------+----------+--------------+------------------+-------------------+ | oldboy-bin.000001 | 405 | | | | +-------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
查看变量:
mysql> show variables like 'log_bin%';
+---------------------------------+----------------------------+
| Variable_name | Value |
+---------------------------------+----------------------------+
| log_bin | ON |
| log_bin_basename | /data/3306/mysql-bin |
| log_bin_index | /data/3306/mysql-bin.index |
| log_bin_trust_function_creators | OFF |
| log_bin_use_v1_row_events | OFF |
+---------------------------------+----------------------------+
5 rows in set (0.00 sec)
2、建账号授权【主库】
grant replication slave on *.* to 'rep'@'172.16.1.%' identified by 'oldboy123';
flush privileges;
3、锁表导出数据
mysql> flush table with read lock;
Query OK, 0 rows affected (0.00 sec)
查看位置:
mysql> show master status;
+-------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| oldboy-bin.000001 | 405 | | | |
+-------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)