在 Slave 端查看是否能够更新:
- root@test2 ~: mysql -u root -p
- Enter password:
- Welcome to the MySQL monitor. Commands end with ; or \g.
- Your MySQL connection id is 6
- Server version: 5.0.45-log Source distribution
-
- Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
-
- mysql> show databases;
- +
- | Database |
- +
- | information_schema |
- | foo|
- | mysql |
- | test |
- |abc |
- +
- 5rows in set (0.00 sec)
- mysql> use abc;
- Reading table information for completion of table and column names
- You can turn off this feature to get a quicker startup with -A
- Database changed
- mysql> show tables;
- +
- | Tables_in_abc |
- +
- | test1 |
- +
- 1 row in set (0.03 sec)
- mysql> select * from test1;
- +
- | IP | USER | MAIL |
- +
- | 192.168.7.66 | test | test@test.com.cn |
- +
- 1 row in set (0.00 sec)
|
从上面的结果可以看到 Master 端的数据可以同步到 Slave 端里面。说明此时主从数据库的同步问题已经成功解决。
三、补充资料
关于如何连接到远程 MySQL 问题,可以采取下面的步骤:
首先先登录到远程机器:
- jian.ma@camlit ~: ssh root@192.168.56.103
- password: xxx
- root@test2 ~:
|
编辑配置文件:
root@test2 ~: vi /etc/my.cnf |
增加下面一行内容:
- [mysqld]
- datadir=/var/lib/mysql
- socket=/var/lib/mysql/mysql.sock
- user=mysql
- old_passwords=1
- bind-address=192.168.56.103###此 IP 地址为 MySQL 本机的 IP 地址
- [mysqld_safe]
- log-error=/var/log/mysqld.log
- pid-file=/var/run/mysqld/mysqld.pi
|
重启服务:
root@test2 ~: /etc/init.d/mysqld restart |
创建测试数据库: