
- 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 SELECT ON all tables in all databases on a server with MySQL?
For this, you can use GRANT SELECT statement as in the below syntax −
GRANT SELECT ON *.* TO 'yourUserName'@'yourHostName';
First list all the user names along with host −
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 | | Emma | localhost | | Jace | localhost | | James | localhost | | John | localhost | | John Doe | localhost | | Michael | localhost | | Mike | localhost | | Robert | localhost | | User1 | localhost | | am | localhost | | hbstudent | localhost | | mysql.infoschema | localhost | | mysql.session | localhost | +------------------+-----------+ 26 rows in set (0.00 sec)
Here is the query to implement GRANT SELECT −
mysql> GRANT SELECT ON *.* TO 'hbstudent'@'localhost'; Query OK, 0 rows affected (0.00 sec)
- Related Articles
- Does grant on *.* apply to databases created after the grant in MySQL?
- How to copy tables or databases from one MySQL server to another MySQL server?
- How can I display all databases in MySQL and for each database show all tables?
- List of non-empty tables in all your MySQL databases?
- How can we check the default character sets of all the MySQL databases we have on the server?
- How to operate on all databases from the MongoDB shell?
- How to display all the tables in MySQL with a storage engine?
- Grant all privileges of a database to a MySQL user?
- How to show all the tables present in the database and server in MySQL using Python?
- MySQL permissions to view all databases?
- How to display all tables in MySQL with InnoDB storage engine?
- How to identify a column with its existence in all the tables with MySQL?
- How can we grant a user to access all stored procedures in MySQL?
- How can we display a list of currently existing MySQL databases on the server?
- How to select all duplicates in MySQL?

Advertisements