mysql主从复制

匿名 (未验证) 提交于 2019-12-02 22:06:11
[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)

文章来源: mysql主从复制
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!