This is the final part in this little mini series.
As you have seen the other parts, we will now complete the setup. First off we will need to get a dump of the primary database, to do this
mysqldump replication_test > dump.sql
From here you need to get this over to your other machine, SCP or open and copy and paste the contents, which ever works for you.
Then on the slave import the database dump.
mysql use replication_test \. dump.sql
Now still on the slave, log in to the database and type the below, now what we need is the Position and the File we saw in step 2 from your output, when you typed show master status.
change master to master_host='192.168.33.10',MASTER_USER='slave', MASTER_PASSWORD='SlavePassword',MASTER_PORT=3306, MASTER_LOG_FILE='localhost-bin.000001', MASTER_LOG_POS=788,MASTER_CONNECT_RETRY=10; MariaDB [(none)]> start slave; Query OK, 0 rows affected (0.03 sec) MariaDB [(none)]> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.33.10 Master_User: slave Master_Port: 3306 Connect_Retry: 10 Master_Log_File: localhost-bin.000001 Read_Master_Log_Pos: 788 Relay_Log_File: localhost-relay-bin.000002 Relay_Log_Pos: 1080 Relay_Master_Log_File: localhost-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: replication_test 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: 788 Relay_Log_Space: 1382 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_SSL_Crl: Master_SSL_Crlpath: Using_Gtid: Current_Pos Gtid_IO_Pos: 0-1-3 Replicate_Do_Domain_Ids: Replicate_Ignore_Domain_Ids: Parallel_Mode: conservative 1 row in set (0.00 sec)
Now on the primary, type unlock tables;
Now you should be all setup, you can try to create tables, or insert rows to your test table and you should see them again on the slave.
I would like any feedback about this article, did it help you, does anything need changing?
I am always interested in your thoughts so if you have any comments or feedback then please feel free to add any comments, or you can mail me here.