[root@foundation13 ~]# scp phpMyAdmin-5.0.2-all-languages.zip server1:/usr/local/lnmp/nginx/html/phpadmin
root@server1's password:
phpMyAdmin-5.0.2-all-languages.zip 100% 14MB 195.1MB/s 00:00
[root@server1 html]# ls
50x.html bbs download example.php index.html index.php memcache.php phpadmin redhat.jpg
[root@server1 html]# unzip phpadmin
[root@server1 html]# ls
50x.html bbs download example.php index.html index.php memcache.php phpadmin phpMyAdmin-5.0.2-all-languages redhat.jpg
[root@server1 html]# rm -fr phpadmin
[root@server1 html]# mv phpMyAdmin-5.0.2-all-languages phpadmin
[root@server1 html]# ls
50x.html bbs download example.php index.html index.php memcache.php phpadmin redhat.jpg
[root@server1 html]# mv phpadmin phpmyadmin
[root@server1 html]# cd ..
[root@server1 nginx]# cd conf
[root@server1 conf]# vim nginx.conf
[root@server1 conf]# nginx -t
nginx: the configuration file /usr/local/lnmp/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/lnmp/nginx/conf/nginx.conf test is successful
[root@server1 conf]# nginx -s reload
[root@server1 conf]# cd ..
[root@server1 nginx]# cd html
[root@server1 html]# ls
50x.html bbs download example.php index.html index.php memcache.php phpmyadmin redhat.jpg
[root@server1 html]# cd /usr/local/lnmp/php
[root@server1 php]# ls
bin etc include lib php sbin var
[root@server1 php]# cd lib
[root@server1 lib]# vim php.ini
[root@server1 lib]# systemctl reload php-fpm
设置远程主机可以连接
[root@server1 phpmyadmin]# pwd
/usr/local/lnmp/nginx/html/phpmyadmin
[root@server1 phpmyadmin]# vim config.inc.php
[root@server1 phpmyadmin]# nginx -s reload
创建root用户,授予对172.25.13网段数据库的全部权限
[root@server3 local]# mysql -pWestos_007
mysql> create user root@'172.25.13.%' identified by 'Westos_007';
Query OK, 0 rows affected (0.02 sec)
mysql> grant all on *.* to root@'172.25.13.%';
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> exit
Bye
[root@server3 local]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
[root@server3 local]# mysql -pWestos_007
mysql> create user lj@'172.25.13.%' identified by 'Westos_007';
Query OK, 0 rows affected (0.02 sec)
mysql> create database westos;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on westos.* to lj@'172.25.13.%'; //只能对westos数据库进行操作
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
[root@server3 local]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
[[root@server1 lib]# vim /etc/my.cnf
[root@server1 lib]# cd /usr/local/lnmp/nginx/html/phpmyadmin
[root@server1 phpmyadmin]# mysql -pWestos_007
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: 8.0.21 Source distribution
Copyright (c) 2000, 2020, 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> create user 'repl'@'172.25.13.%' identified by 'Westos_007';
Query OK, 0 rows affected (0.01 sec)
mysql> grant replication slave on *.* to 'repl'@'172.25.13.%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
/etc/my.cnf
[root@server1 lib]# vim /etc/my.cnf
[root@server1 phpmyadmin]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL. SUCCESS!
[root@server3 local]# vim /etc/my.cnf
[root@server3 local]# /etc/init.d/mysqld restart
Shutting down MySQL.. SUCCESS!
Starting MySQL.. SUCCESS!
[root@server3 local]# mysql -h 172.25.13.1 -urepl -pWestos_007
mysql> show database;
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 'database' at line 1
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
+--------------------+
1 row in set (0.00 sec)
[root@server3 local]# mysql -pWestos_007
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 116
Server version: 8.0.21 Source distribution
Copyright (c) 2000, 2020, 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> CHANGE MASTER TO
-> MASTER_HOST='172.25.13.1',
-> MASTER_USER='repl',
-> MASTER_PASSWORD='Westos_007',
-> MASTER_LOG_FILE='mysql-bin.000001',
-> MASTER_LOG_POS=156,
-> GET_MASTER_PUBLIC_KEY=1;
Query OK, 0 rows affected, 2 warnings (0.05 sec)
mysql> START SLAVE;
Query OK, 0 rows affected (0.01 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.25.13.1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 156
Relay_Log_File: server3-relay-bin.000003
Relay_Log_Pos: 509
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
server1:
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 156 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> CREATE DATABASE test;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.01 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 341 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> exit
server3:
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.25.13.1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 341
Relay_Log_File: server3-relay-bin.000003
Relay_Log_Pos: 509
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
| westos |
+--------------------+
6 rows in set (0.01 sec)
mysql> exit
server1
[root@server1 phpmyadmin]# mysql -pWestos_007
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 83
Server version: 8.0.21 Source distribution
Copyright (c) 2000, 2020, 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 master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000002 | 778 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> use 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 |
+----------------+
| client |
+----------------+
1 row in set (0.00 sec)
mysql> select * from client;
+--------+----------+--------+
| name | password | city |
+--------+----------+--------+
| 小海 | 1234566 | 成都 |
| 陈兵 | 333333 | 海南 |
+--------+----------+--------+
2 rows in set (0.00 sec)
server2
[root@server3 local]# mysql -pWestos_007
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 149
Server version: 8.0.21 Source distribution
Copyright (c) 2000, 2020, 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 tables;
+----------------+
| Tables_in_test |
+----------------+
| client |
| user |
+----------------+
2 rows in set (0.00 sec)
mysql> select client;
ERROR 1054 (42S22): Unknown column 'client' in 'field list'
mysql> select * from client;
+--------+----------+--------+
| name | password | city |
+--------+----------+--------+
| 小海 | 1234566 | 成都 |
| 陈兵 | 333333 | 海南 |
+--------+----------+--------+
2 rows in set (0.00 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.25.13.1
Master_User: repl
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000002
Read_Master_Log_Pos: 778
Relay_Log_File: server3-relay-bin.000005
Relay_Log_Pos: 993
Relay_Master_Log_File: mysql-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: