3.改好后保存退出,然后建立一个slave服务器的用户账号
root@msyql1:/# mysql -uroot -p
mysql> grant replication slave,replication client on *.* to ludy@'192.168.6.5' identified by 'ypmwbg';
mysql > grant replication slave on *.* to ludy@192.168.6.5 identified by 'ypmwbg'; //给予权限
到这里要注意了,我的两台数据库都是空的.
然后进入 mysql1 master 服务器
root@msyql:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.51a-3ubuntu5.4-log (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 98 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
记录下来以后 进入 mysql2 slave mysql
root@msyql2:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.51a-3ubuntu5.4-log (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> change master to master_log_file='mysql-bin.000001', master_log_pos=98;
root@msyq1l:/# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.0.51a-3ubuntu5.4-log (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.