O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required