Granting privileges

  • Grant the READ ONLY(SELECT) privileges to the company_read_only user:
mysql> GRANT SELECT ON company.* TO 'company_read_only'@'localhost';Query OK, 0 rows affected (0.06 sec)

The asterisk (*) represents all tables inside the database.

  • Grant the INSERT privilege to the new company_insert_only user:
mysql> GRANT INSERT ON company.* TO 'company_insert_only'@'localhost' IDENTIFIED BY 'xxxx';Query OK, 0 rows affected, 1 warning (0.05 sec)
mysql> SHOW WARNINGS\G*************************** 1. row ***************************  Level: Warning   Code: 1287Message: Using GRANT for creating new user is deprecated and will be removed in future release. Create new user with CREATE USER statement.1 row in set (0.00 sec)
  • Grant the 

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.