7.init db
# su - mysql
Last login: Tue Sep 5 14:26:36 CST 2017 on pts/0
-bash-4.2$ cd /usr/local/mysql-5.6.37
-bash-4.2$ scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql-5.6.37 --datadir=/usr/local/mysql-5.6.37/data
-bash-4.2$ exit
logout
9.启动mysql
# service mysql start
8.登录mysql及改密码与配置远程访问
#登录mysql,密码为空
# mysql -u root -p
#允许root用户远程访问
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
#刷新权限
mysql>FLUSH PRIVILEGES;
mysql>exit
mysql> show variables like 'server%';
+----------------+--------------------------------------+
| Variable_name | Value |
+----------------+--------------------------------------+
| server_id | 1 |
| server_id_bits | 32 |
| server_uuid | 4875d4d5-9211-11e7-90ac-000c29e56ccc |
+----------------+--------------------------------------+
3 rows in set (0.04 sec)
mysql>
mysql>
2).salve
mysql> show variables like 'server%';
+----------------+--------------------------------------+
| Variable_name | Value |
+----------------+--------------------------------------+
| server_id | 2 |
| server_id_bits | 32 |
| server_uuid | eb40bb6a-920d-11e7-9096-000c29e0d6fa |
+----------------+--------------------------------------+
3 rows in set (0.04 sec)
mysql>
2.master建立复制用户
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000003 | 120 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> grant replication slave,replication client on *.* to 'replic_user'@'172.16.3.%' identified by 'repl123456';
Query OK, 0 rows affected (0.28 sec)
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.3.226
Master_User: replic_user
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 433
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 596
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 433
Relay_Log_Space: 769
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
Master_UUID: 4875d4d5-9211-11e7-90ac-000c29e56ccc
Master_Info_File: /usr/local/mysql-5.6.37/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
ERROR:
No query specified
master建立测试库
mysql> create database db1;
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'172.16.3.%' IDENTIFIED BY '123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.29 sec)
[iyunv@mycat conf]# mysql -u mycat -h 172.16.3.229 -P 8066 -pmycat123456 -D TESTDB
Warning: Using a password on the command line interface can be insecure.
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.6.29-mycat-1.6-RELEASE-20161028204710 MyCat Server (OpenCloundDB)
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.