CentOS 7.4下MySQL 5.7.20主从环境搭建(M(5)

[root@xuegodslave ~]# mysql -uslave -p'A@*qw92!derS' -h 10.10.10.69  在slave服务器上使用授权账号slave登录master mysql测试授权账号能否登录
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.7.20-log MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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>

mysql> show databases;  
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)

 如上所示查询不到test测试数据库

mysql> exit;  退出master数据库
Bye

 

[root@xuegodslave ~]# mysql -uroot -p'zX@987Weqqrd1'  登录slave服务器,密码初始化与master相同
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 5.7.20 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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>

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.01 sec)

mysql> create database test;  创建测试数据库
Query OK, 1 row affected (0.01 sec)

mysql> exit;  退出数据库
Bye
[root@xuegodslave ~]# mysql -uroot -p'zX@987Weqqrd1' test<test.sql  将master导出的数据库内容导入slave创建的test数据库内
mysql: [Warning] Using a password on the command line interface can be insecure.

[root@xuegodslave ~]# mysql -uroot -p'zX@987Weqqrd1'   登录slave服务器
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.20 MySQL Community Server (GPL)

Copyright (c) 2000, 2017, 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 |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.00 sec)

mysql> use test; 切换到test数据库
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_test |
+----------------+
| test1 |    已存在master服务器创建的表test1,导入成功
+----------------+
1 row in set (0.00 sec)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d0dc1a0ec1963245a3681386c9c2b706.html