6、SSH登录到主数据库:
(1)在主数据库上创建用于主从复制的账户(192.168.100.3换成你的从数据库IP):
1 # mysql -uroot -p
2 mysql> GRANT REPLICATION SLAVE ON *.* TO ‘repl‘@‘192.168.100.3‘ IDENTIFIED BY ‘repl‘;
(2)主数据库锁表(禁止再插入数据以获取主数据库的的二进制日志坐标):
1 mysql> FLUSH TABLES WITH READ LOCK;
(3)然后克隆一个SSH会话窗口,在这个窗口打开MySQL命令行:
1 # mysql -uroot -p
2 mysql> SHOW MASTER STATUS;
3 +------------------------+----------+--------------+------------------+-------------------+
4 | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
5 +------------------------+----------+--------------+------------------+-------------------+
6 | mysqlmaster-bin.000001 | 332 | | | |
7 +------------------------+----------+--------------+------------------+-------------------+
8 1 row in set (0.00 sec)
9 mysql> exit;