diff --git a/MySQL.md b/MySQL.md new file mode 100644 index 0000000..ed1bbd2 --- /dev/null +++ b/MySQL.md @@ -0,0 +1,53 @@ +# MySQK + +## Replication + +### Primary server + +Config-file +
[mysqld]
+server_id = 1
+log_bin = "/path/to/MySQL-bin.log"
+# disable_log_bin
+binlog_do_db = database-to-replicate
+
+
+SQL
+
+CREATE USER 'replication'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
+GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%';
+FLUSH PRIVILEGES;
+SHOW MASTER STATUS;
+
+
+### Slave server
+
+Config-file
+[mysqld]
+server_id = 2
+log_bin = "/path/to/MySQL-bin.log"
+# disable_log_bin
+binlog_do_db = database-to-replicate
+relay-log = "/path/to/relay.log"
+
+
+SQL
+
+-- For MySQL > 8.0
+CHANGE REPLICATION SOURCE TO SOURCE_USER='replication', SOURCE_PASSWORD='password', SOURCE_HOST='192.168.0.2', SOURCE_LOG_FILE='MySQL-bin.000001', SOURCE_LOG_POS=155;
+
+-- For MySQL <= 8.0
+CHANGE MASTER TO
+ MASTER_HOST='192.168.0.2',
+ MASTER_USER='replication',
+ MASTER_PASSWORD='password',
+ MASTER_PORT=3306,
+ MASTER_LOG_FILE='MySQL-bin.000001',
+ MASTER_LOG_POS=466,
+ MASTER_CONNECT_RETRY=10;
+
+START REPLICA;
+STOP REPLICA;
+
+SHOW REPLICA STATUS;
+
\ No newline at end of file