MySQL – Syntax Error Changing Master for Channel

mariadbmariadb-10.1MySQLreplication

I'm trying to set up a multi-source replication

When trying to set a master for a specific channel using this query

CHANGE MASTER TO MASTER_HOST='192.168.0.203', MASTER_USER='rep', MASTER_PORT=3306, MASTER_PASSWORD='pass', MASTER_LOG_FILE='mysql-bin.000003', MASTER_LOG_POS=107 FOR CHANNEL 'master-203';

I get the following error

Error Code: 1064. You have an error in your SQL syntax; check the
manual that corresponds to your MariaDB server version for the right
syntax to use near 'FOR CHANNEL 'master-203'' at line 1

I can't figure out what's the problem. The query is pretty much a copy-paste from the official documentation

My server is running MariaDB 10.1.21

What could be wrong?

Best Answer

You're looking at the documentation for MySQL 5.7, but you're running MariaDB 10.1, and replication channels happen to be a feature that is implemented differently in MariaDB.

From the MariaDB documentation on multi-source replication:

You specify which master connection you want to work with by either specifying the connection name in the command or setting default_master_connection to the connection you want to work with.

So in your case you could try:

CHANGE MASTER 'master-203' TO MASTER_HOST='192.168.0.203', 
MASTER_USER='rep', 
MASTER_PORT=3306, 
MASTER_PASSWORD='pass', 
MASTER_LOG_FILE='mysql-bin.000003', 
MASTER_LOG_POS=107; 

(Disclaimer: I've not tried this in practice.)