
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to 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)
- Related Articles
- Grant all privileges of a database to a MySQL user?
- Oracle DataBase – Grant Privileges to a User in SQL Command Line
- How can we grant privileges to a MySQL user?
- How to display grant defined for a MySQL user?
- Does grant on *.* apply to databases created after the grant in MySQL?
- How can we grant a user to access all stored procedures in MySQL?
- Grant a user permission to only view a MySQL view?
- MySQL query to create user and grant permission
- Check replication type in MySQL?
- How to GRANT SELECT ON all tables in all databases on a server with MySQL?
- How to alter the database engine of a MySQL database table?
- How to list all triggers in a MySQL database?
- How to update two columns in a MySQL database?
- How to insert a Python tuple in a MySQL database?
- How to check if a MySQL database exists?

Advertisements