I am trying to create a stored procedure that can run change master to command.
This is what I was able to come up with.
DELIMITER //
CREATE PROCEDURE changeMasterTo(IN ip char(20),IN port int,IN user
char(30),IN password char(30))
LANGUAGE SQL
COMMENT 'changes master to'
ThisStoredProcedure:BEGIN
CHANGE MASTER TO MASTER_HOST=ip,
MASTER_PORT=port,
MASTER_USER=user,
MASTER_PASSWORD=password,
MASTER_AUTO_POSITION=1,
MASTER_SSL=1;
END;
//
But it fails with the following error.
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
'ip,
MASTER_PORT=port,
MASTER_USER=user,
MASTER_PASSWORD=password,
MASTER_AUTO_P'at line 5
I am not sure what the issue is, any help will be appreciated.
Best Answer
The
host
,user
, andpassword
values are supposed to be enclosed in single quotes.You are also better off executing it as Dynamic SQL