- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to GRANT SELECT ON all tables in all databases on a server with MySQL?
152 Lectures 16 hours
87 Lectures 5.5 hours
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)
- 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 to operate on all databases from the MongoDB shell?
- 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 can I display all databases in MySQL and for each database show all tables?
- MySQL permissions to view all databases?
- Grant all privileges of a database to a MySQL user?
- How can we display a list of currently existing MySQL databases on the server?
- A single MySQL select query on two tables is possible?
- How to display all constraints on a table in MySQL?
- Select all duplicate MySQL rows based on one or two columns?
- How to display all the tables in MySQL with a storage engine?
- How can we grant a user to access all stored procedures in MySQL?
- How to select all duplicates in MySQL?