These are the commands you will need to write into the MySQL console:
1. Delete the database from the previous examples.
DROP DATABASE NeatTreats;
2. Create a database with a product table.
CREATE DATABASE NeatTreats;
USE NeatTreats;
CREATE TABLE Product (
ProductID INT,
Name VARCHAR(125),
Price FLOAT,
);
3. Create the users for your connection (localhost) and choose sensible password.
CREATE USER Customer@localhost IDENTIFIED BY ‘CustomerPassword123’;
CREATE USER Admin@localhost IDENTIFIED BY ‘AdminPassword123’;
4. Assign the query privileges you want each user to have on the product table.
GRANT SELECT ON Product TO Customer@localhost;
GRANT SELECT, UPDATE, DELETE ON Product TO Admin@localhost;
Parent topic: Example 3
Top comments (0)