Add MySQL docs

This commit is contained in:
Johan 2024-08-29 10:03:15 +02:00
parent 9e91cb5022
commit ac171bd009

53
MySQL.md Normal file
View File

@ -0,0 +1,53 @@
# MySQK
## Replication
### Primary server
Config-file
<pre><code>[mysqld]
server_id = 1
log_bin = "/path/to/MySQL-bin.log"
# disable_log_bin
binlog_do_db = database-to-replicate
</code></pre>
SQL
<pre><code>
CREATE USER 'replication'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'replication'@'%';
FLUSH PRIVILEGES;
SHOW MASTER STATUS;
</code></pre>
### Slave server
Config-file
<pre><code>[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"
</code></pre>
SQL
<pre><code>
-- 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;
</code></pre>