测试可以正常连接,但是没有发现abaotest数据库。
3.2、导入数据库,使其与主服务器一致: [root@abao67 ~]# mysql -u root -p12345 < all.sql [root@abao67 ~]# 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.5.32-log Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | abaotest | | mysql | | performance_schema | | test | +--------------------+ 5 rows in set (0.00 sec) mysql> use abaotest Database changed mysql> select * from category; +---------+---------------+ | bTypeId | bTypeName | +---------+---------------+ | 1 | windows应用 | | 2 | 网站 | | 3 | 3D动画 | | 4 | linux学习 | | 5 | Delphi学习 | | 6 | 黑客 | | 7 | 网络技术 | | 8 | 安全 | | 9 | 平面 | | 10 | AutoCAD技术 | +---------+---------------+ 10 rows in set (0.00 sec) 3.3、修改从服务器abao67配置文件:配置MySQL从服务器的my.cnf文件
vi /etc/my.cnf #编辑配置文件,在[mysqld]部分添加下面内容
server-id=2 #配置文件中已经有一行server-id=1,修改其值为2,表示为从数据库
log-bin=mysql-bin #启动MySQ二进制日志系统,注意:如果原来的配置文件中已经有这一行,就不用再添加了。
replicate-do-db=osyunweidb #需要同步的数据库名,如果有多个数据库,可重复此参数,每个数据库一行
replicate-ignore-db=mysql #不同步mysql系统数据库
:wq! #保存退出