
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Grant Replication Privilege to a Database in MySQL
To grant replication privilege, use GRANT REPLICATION SLAVE ON.
First list all the user names along with host from MySQL.user table −
mysql> select user,host from mysql.user;
This will produce the following output −
+------------------+-----------+ | user | host | +------------------+-----------+ | Bob | % | | Charlie | % | | Robert | % | | User2 | % | | mysql.infoschema | % | | mysql.session | % | | mysql.sys | % | | root | % | | @UserName@ | localhost | | Adam | localhost | | Adam Smith | localhost | | Chris | localhost | | David | localhost | | James | localhost | | John | localhost | | John Doe | localhost | | Mike | localhost | | User1 | localhost | | am | localhost | | hbstudent | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | +------------------+-----------+ 22 rows in set (0.00 sec)
Let us implement the above syntax to grant replication privilege to a database in MySQL −
mysql> GRANT REPLICATION SLAVE ON *.* TO 'Mike'@'localhost'; Query OK, 0 rows affected (0.20 sec)
Let us check the grant is successful or not −
mysql> SHOW GRANTS FOR 'Mike'@'localhost';
This will produce the following output −
+------------------------------------------------------+ | Grants for Mike@localhost | +------------------------------------------------------+ | GRANT REPLICATION SLAVE ON *.* TO `Mike`@`localhost` | +------------------------------------------------------+ 1 row in set (0.04 sec)
Advertisements