What are the minimum MySQL user privileges to allow optimize and repair?

MySQLMySQLi Database

The select and insert statements are the minimum required MySQL user privileges to allow optimize and repair.

You can use below syntax to give insert and select privileges to the user −

grant insert,select on yourDatabaseName.* to 'yourUserName'@'localhost';

At first, here is the query to create a user −

mysql> create user 'Emma'@'localhost' identified by 'Emma123';
Query OK, 0 rows affected (0.26 sec)

Here is the query to give grants for the above user −

mysql> grant insert,select on web.* to 'Emma'@'localhost';
Query OK, 0 rows affected (0.21 sec)

Here is the query to display all grants of the above user −

mysql> show grants for 'Emma'@'localhost';

This will produce the following output −

+-------------------------------------------------------+
| Grants for Emma@localhost                             |
+-------------------------------------------------------+
| GRANT USAGE ON *.* TO `Emma`@`localhost`              |
| GRANT SELECT, INSERT ON `web`.* TO `Emma`@`localhost` |
+-------------------------------------------------------+
2 rows in set (0.00 sec)
raja
Published on 17-Dec-2019 10:21:08
Advertisements