1、实验环境准备:
A、mysql主服务器 名称:abao68 IP地址:192.168.1.68 数据库版本为:mysql5.1.72
[root@CentOS67-68 ~]# mysql -V
mysql Ver 14.14 Distrib 5.1.73, for RedHat-linux-gnu (x86_64) using readline 5.1
[root@centos67-68 ~]# uname -a
Linux centos67-68 2.6.32-642.15.1.el6.x86_64 #1 SMP Fri Feb 24 14:31:22 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
B、mysql从服务器 名称:abao67 IP地址:192.168.1.67 数据库版本为:mysql5.5.32
[root@abao67 ~]# mysql -V
mysql Ver 14.14 Distrib 5.5.32, for Linux (x86_64) using readline 5.1
[root@abao67 ~]# uname -a
Linux abao67 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
2、试验数据准备: 2.1、在主服务器abao68创建数据库名称为abaotest数据库,并导入测试数据。 [root@centos67-68 ~]# mysql -V mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1 [root@centos67-68 ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.73 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 | | mysql | | test | +--------------------+ 3 rows in set (0.00 sec) mysql> create database abaotest; Query OK, 1 row affected (0.00 sec) mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | abaotest | | mysql | | test | +--------------------+ 4 rows in set (0.00 sec) 2.2、把测试数据导入刚才我们新建的abaotest数据库:方法一:
[root@centos67-68 ~]# mysql -uroot -p abaotest < book_utf8.sql Enter password:方法二:
mysql> user abaotest; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'user abaotest' at line 1 mysql> use abaotest 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> source /root/book_utf8.sql查看刚导入的数据表情况:
mysql> show tables; +--------------------+ | Tables_in_abaotest | +--------------------+ | books | | category | +--------------------+ 2 rows in set (0.00 sec) 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)