DEV Community

David Kanekanian
David Kanekanian

Posted on

E3 - Setting Up Database

These are the commands you will need to write into the MySQL console:

1. Delete the database from the previous examples.

DROP DATABASE NeatTreats; 
Enter fullscreen mode Exit fullscreen mode

2. Create a database with a product table.

CREATE DATABASE NeatTreats; USE NeatTreats; CREATE TABLE Product ( ProductID INT, Name VARCHAR(125), Price FLOAT, ); 
Enter fullscreen mode Exit fullscreen mode

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; 
Enter fullscreen mode Exit fullscreen mode

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; 
Enter fullscreen mode Exit fullscreen mode

Parent topic: Example 3

Top comments (0)