I need to create a user with REPLICATION SLAVE
privilege for each database.
When I use the command:
GRANT REPLICATION SLAVE ON `mydb`.* TO 'user';
The error is shown:
Incorrect usage of DB GRANT and GLOBAL PRIVILEGES
Is there a way to grant REPLICATION SLAVE
privilege to only a database?
You can't restrict GRANT REPLICATION SLAVE
to only one database, so you must use
GRANT REPLICATION SLAVE ON *.* TO 'user'@'host'
But you can restrict the replication itself :
--replicate-do-db=db_name
As the latter is rather for the slave server, it can easily be messed up with. So you'll want to do it on the master server, using either :
[mysqld]
binlog-do-db=replicated_db_name
for the databases that you want to replicate
binlog-ignore-db=ignored_db_name
for the databases that you don't want to be replicated
Excluding databases on the server using the last two commands, has the effect that no statement about them will be included in the binary log file which will compromise the backup procedure.