GRANT REPLICATION SLAVE ON - ERROR 1064 (42000): You have an error in your SQL syntax

I’m setting up mysql replication using xtrabackup guide How to set up a replica for replication in 6 simple steps with Percona XtraBackup - Percona XtraBackup

On Master/Source I’m running this command

mysql> GRANT REPLICATION SLAVE ON *.* TO 'root'@'12.34.56.78' IDENTIFIED BY 'asdfd34F4fg';

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 'IDENTIFIED BY 'asdfd34F4fg'' at line 1

How to fix it?

Hi @roger . Thanks for reaching out.

This command is obsolete (You can’t create an user using the GRANT command anymore); which is why you’re facing the error.

Please try like this:

CREATE USER user@'X.X.X.X' IDENTIFIED BY '<STRONG_PASSWORD>';
GRANT REPLICATION SLAVE ON *.* TO  user@'X.X.X.X' ;

And I’ll check internally to fix the documentation, thanks for flagging it.

Best,
Mauricio.

Thanks for reply. That works.